Browse Source

Issue #2212: documentation: virtualenv and python3

pull/2213/head
Runar Trollet Kristoffersen 8 years ago
parent
commit
889c0ed196
  1. 41
      docs/installation.rst

41
docs/installation.rst

@ -40,6 +40,12 @@ installations of Python, one for each project. It doesn't actually install
separate copies of Python, but it does provide a clever way to keep different separate copies of Python, but it does provide a clever way to keep different
project environments isolated. Let's see how virtualenv works. project environments isolated. Let's see how virtualenv works.
.. admonition:: A note on python3 and virtualenv
If you are planning on using python3 with the virtualenv, you don't need to
install ``virtualenv``. Python3 has built-in support for virtual environments.
If you are on Mac OS X or Linux, chances are that the following If you are on Mac OS X or Linux, chances are that the following
command will work for you:: command will work for you::
@ -55,24 +61,43 @@ install it first. Check the :ref:`windows-easy-install` section for more
information about how to do that. Once you have it installed, run the same information about how to do that. Once you have it installed, run the same
commands as above, but without the ``sudo`` prefix. commands as above, but without the ``sudo`` prefix.
Creating a virtual environment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Once you have virtualenv installed, just fire up a shell and create Once you have virtualenv installed, just fire up a shell and create
your own environment. I usually create a project folder and a :file:`venv` your own environment. I usually create a project folder and a :file:`virtenv`
folder within:: folder within::
$ mkdir myproject $ mkdir myproject
$ cd myproject $ cd myproject
$ virtualenv venv
New python executable in venv/bin/python There is a little change in how you create a virtualenv depending on which python-version you are currently using.
**Python2**
::
$ virtualenv virtenv
New python executable in virtenv/bin/python
Installing setuptools, pip............done. Installing setuptools, pip............done.
**Python 3.6 and above**
::
$ python3 -m venv virtenv
Activating a virtual environment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Now, whenever you want to work on a project, you only have to activate the Now, whenever you want to work on a project, you only have to activate the
corresponding environment. On OS X and Linux, do the following:: corresponding environment. On OS X and Linux, do the following::
$ . venv/bin/activate $ . virtenv/bin/activate
If you are a Windows user, the following command is for you:: If you are a Windows user, the following command is for you::
$ venv\Scripts\activate $ virtenv\Scripts\activate
Either way, you should now be using your virtualenv (notice how the prompt of Either way, you should now be using your virtualenv (notice how the prompt of
your shell has changed to show the active environment). your shell has changed to show the active environment).
@ -115,10 +140,10 @@ Get the git checkout in a new virtualenv and run in development mode::
$ git clone https://github.com/pallets/flask.git $ git clone https://github.com/pallets/flask.git
Initialized empty Git repository in ~/dev/flask/.git/ Initialized empty Git repository in ~/dev/flask/.git/
$ cd flask $ cd flask
$ virtualenv venv $ virtualenv virtenv
New python executable in venv/bin/python New python executable in virtenv/bin/python
Installing setuptools, pip............done. Installing setuptools, pip............done.
$ . venv/bin/activate $ . virtenv/bin/activate
$ python setup.py develop $ python setup.py develop
... ...
Finished processing dependencies for Flask Finished processing dependencies for Flask

Loading…
Cancel
Save