Skip to content
Myr

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

1 file+33 added−8 removed

modified:docs/installation.rst+33 added-8 removed
38 unmodified lines
39installations of Python, one for each project. It doesn't actually install40separate copies of Python, but it does provide a clever way to keep different41project environments isolated. Let's see how virtualenv works.424344.. admonition:: A note on python3 and virtualenv4546 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.4849If you are on Mac OS X or Linux, chances are that the following50command will work for you::5152 $ sudo pip install virtualenv
7 unmodified lines
60install it first. Check the :ref:`windows-easy-install` section for more61information about how to do that. Once you have it installed, run the same62commands as above, but without the ``sudo`` prefix.6364Creating a virtual environment65~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~6667Once you have virtualenv installed, just fire up a shell and create59your own environment. I usually create a project folder and a :file:`venv`68your own environment. I usually create a project folder and a :file:`virtenv`69folder within::7071 $ mkdir myproject72 $ cd myproject7374There is a little change in how you create a virtualenv depending on which python-version you are currently using.7576**Python2**7778::7964 $ virtualenv venv65 New python executable in venv/bin/python80 $ virtualenv virtenv81 New python executable in virtenv/bin/python82 Installing setuptools, pip............done.8384**Python 3.6 and above**8586::8788 $ python3 -m venv virtenv8990Activating a virtual environment91~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~9293Now, whenever you want to work on a project, you only have to activate the94corresponding environment. On OS X and Linux, do the following::9571 $ . venv/bin/activate96 $ . virtenv/bin/activate9798If you are a Windows user, the following command is for you::9975 $ venv\Scripts\activate100 $ virtenv\Scripts\activate101102Either way, you should now be using your virtualenv (notice how the prompt of103your shell has changed to show the active environment).104
34 unmodified lines
139140 $ 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