Install the virtual environment and environment configuration in ubuntu in python programming.

Source: Internet
Author: User

Install the virtual environment and environment configuration in ubuntu in python programming.

1. Upgrade python package management tool pip

Pip install -- upgrade pip Note: When you want to upgrade a package, 'pip install -- upgrade package name'

2. python Virtual Environment Installation

sudo apt-get install python-virtualenvsudo easy_install virtualenvwrapper

After the tool is installed, the mkvirtualenv command cannot be found. You need to execute the following environment variable settings.

1. Create a directory to store the virtual environment mkdir $ HOME/. virtualenvs2 ~ /. Add row in bashrc: export WORKON_HOME = $ HOME/. virtualenvs source/usr/local/bin/virtualenvwrapper. sh3. run: source ~ /. Bashrc

3. Create a python Virtual Environment

Mkvirtualenv [Virtual Environment name] workon [Virtual Environment name]

4. Exit the virtual environment and leave deactivate.

5. Delete (use with caution)
Rmvirtualenv [Virtual Environment name]

Python 2 Development

Create a virtual development environment for python2

Mkvirtualenv-p/usr/bin/python2.7 xwp_py2

(Because on ubuntu, I installed python2.7 in/usr/bin/. xwp_py2 is the name of my own virtual environment)

To use the python2.7 + django1.7.8 environment, you should install the following environment:

(Xwp_py2) itcast @ itcast :~ /Workspace/itcast_project $ pip freeze list // after entering a virtual environment, this command is used to view the installation configuration of the local environment. If these environments are not available, next, let's look at pip = 8.1.0Django = 1.7.8ipdb = 0.8.1ipython = 3.2.0Pillow = 2.8.2.

Store the package name to package_py2.txt. In your python virtual environment, run the following file: // package_py2.txt, which is used to execute the following command:

pip install -r package_py2.txt
Python 3 Development

Our courses are based on Python2.7, because many third-party libraries have not been overly developed into the python3 series.

Create a virtual development environment for python3

mkvirtualenv -p /usr/bin/python3.4 xwp_py3

To use the python3.4 + django1.9.4 environment, you should install the following environment:

(xwp_py3)itcast@itcast:~/workspace/itcast_project$ pip freeze listpip==8.1.0Django==1.9.4ipdb==0.8.1ipython==4.1.2Pillow==2.8.2

Store the package name to package_py3.txt. In your python virtual environment, run:

pip install -r package_py3.txt
Pip command quick query
  • View installed packages

    Pip show -- files SomePackage

  • Check which packages need to be updated

    Pip list -- outdated

  • Upgrade package

    Pip install -- upgrade SomePackage

  • Uninstall package

    Pip uninstall SomePackage

  • Parameter description

    Pip -- help

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.