Build Virtualenv+python3.4+flask in Ubantu

Source: Internet
Author: User
Tags virtual environment virtualenv

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.