The previous article is based on the ubantu14.04 of the Python2.7 built Virtualenv+python+flask (need to pay special attention to the problem of the folder is Chinese), busy today for three hours, a large number of online access to complete the data virtualenv+ Python3.4+flask build, if not alone hit a python3 environment out, run Python3 file is unable to find flask, because 3 and 2 is a conflict, so it is advisable to build a python3 virtual environment, The two can also be toggled (Type command: Deactivate), below is the detailed steps:
1. Install virtualenv in normal environment
$sudo Apt-get Install Python-virtualenv
2. Installing python3.4
$sudo Apt-get Install python3.4
After the installation is complete, you can enter the command: Python3
If it appears
If the installation succeeds, enter quit () to exit.
3. Locate the Python3 installation directory
$sudo gedit/etc/environment
Generally in the/usr/local/bin/python3.4 under, also some under/usr/bin/python3.4, we can look for a bit.
4. Create a PYTHON3 virtual environment based on the directory found above
Use the/usr/local/bin/python3.4 environment to create a virtual environment named Py3env:
$virtualenv-P/usr/local/bin/python3.4 py3env
To activate a virtual environment:
$source py3env/bin/activate
Activation success will be displayed at the top of the line (py3env)$:
This is the input python and you can see that the 3.4 version is displayed
Cancel activation:
(py3env) [email protected]:~$ deactivate
Enter python again, and you'll find that it's back to version 2.7.
This creates a Python3 virtual environment, but it has to be installed flask
5. In this environment (PY3ENV) Install the flask, note that it is installed in an environment-activated state:
(py3env) [Email protected]:~$ pip Install flask
This environment is basically built, you can write a small demo test. At the end of the last article, this is not a repeat.
Build Virtualenv+python3.4+flask in Ubantu