Issue #2212: documentation: virtualenv and python3
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Runar Trollet Kristoffersen · committed by Runar Trollet Kristoffersen · parent 6efea34 · Browse files · 1 file·+33 added−8 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+33 added−8 removed
- other:+33 added−8 removed
Provenance
- Commit
889c0ed- Tree
0947d09- Author
Runar Trollet Kristoffersen <runartrollet@me.com>- Committer
Runar Trollet Kristoffersen <runartrollet@me.com>- Parent
6efea34
1 file changed+33 added−8 removed
modified:docs/installation.rst+33 added-8 removed
38 unmodified lines39 installations of Python, one for each project. It doesn't actually install40 separate copies of Python, but it does provide a clever way to keep different41 project environments isolated. Let's see how virtualenv works.42 43+44+.. admonition:: A note on python3 and virtualenv45+46+ If you are planning on using python3 with the virtualenv, you don't need to47+ install ``virtualenv``. Python3 has built-in support for virtual environments.48+49 If you are on Mac OS X or Linux, chances are that the following50 command will work for you::51 52 $ sudo pip install virtualenv7 unmodified lines60 install it first. Check the :ref:`windows-easy-install` section for more61 information about how to do that. Once you have it installed, run the same62 commands as above, but without the ``sudo`` prefix.63 64+Creating a virtual environment65+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~66+67 Once you have virtualenv installed, just fire up a shell and create59-your own environment. I usually create a project folder and a :file:`venv`68+your own environment. I usually create a project folder and a :file:`virtenv`69 folder within::70 71 $ mkdir myproject72 $ cd myproject73+74+There is a little change in how you create a virtualenv depending on which python-version you are currently using.75+76+**Python2**77+78+::79+64- $ virtualenv venv65- New python executable in venv/bin/python80+ $ virtualenv virtenv81+ New python executable in virtenv/bin/python82 Installing setuptools, pip............done.83 84+**Python 3.6 and above**85+86+::87+88+ $ python3 -m venv virtenv89+90+Activating a virtual environment91+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~92+93 Now, whenever you want to work on a project, you only have to activate the94 corresponding environment. On OS X and Linux, do the following::95 71- $ . venv/bin/activate96+ $ . virtenv/bin/activate97 98 If you are a Windows user, the following command is for you::99 75- $ venv\Scripts\activate100+ $ virtenv\Scripts\activate101 102 Either way, you should now be using your virtualenv (notice how the prompt of103 your shell has changed to show the active environment).104 34 unmodified lines139 140 $ git clone https://github.com/pallets/flask.git141 Initialized empty Git repository in ~/dev/flask/.git/142 $ cd flask118- $ virtualenv venv119- New python executable in venv/bin/python143+ $ virtualenv virtenv144+ New python executable in virtenv/bin/python145 Installing setuptools, pip............done.121- $ . venv/bin/activate146+ $ . virtenv/bin/activate147 $ python setup.py develop148 ...149 Finished processing dependencies for Flask150 40 unmodified lines