on how to implement multiple versions of Python coexistence in virtualenv

Source: Internet
Author: User
Tags virtual environment virtualenv
Virtualenv is used to create a standalone Python environment where multiple python is independent from each other and is capable of: 1. Install the new Suite 2 without permission. Different apps can use a different suite version 3. Package upgrade does not affect other apps

Virtualenv creates an environment with its own installation directory, which does not share libraries with other virtual environments, makes it easy to manage Python versions and manage Python libraries. It mainly solves the problem of environment conflict between different projects.

Little Tricks

Some development packages will be downloaded in the case of download error, if you configure the domestic image download, then the chance of error will be greatly reduced. Using the image source is simple, specifying it with-I is OK:

sudo pip install-i https://pypi.douban.com/simple/saltTesting

For example, now you need to install the Django environment


Virtualenv use

If you need to uninstall Django you can usepip uninstall django

virtualenv Basic Use a standalone environment that requires a new virtualenv after installation to view its Help commands:


Basic commands

The commonly used parameters are:

-P: Specifies a version of the Python environment, which is typically used when multiple Python versions are installed on your system, and by default virtualenv takes precedence over its hosting Python environment. That is, it installs under that Python version and chooses which version will default to the default Python isolation environment.
--no-site-packages: A Python installation package that does not use the system environment, that is, an installation package in which the real Python environment cannot be used in the quarantine package; The current version is the default.
--system-site-packages: A Python installation package that, contrary to the above, enables the isolated environment to access the system environment
--distribute:copy a branch of a Python environment that installs basic modules such as Setup, Pip, wheel, etc. by default

Virtualenv test, use this command to create a python environment under the specified path, which is consistent with the system environment by default. If you want to enter the virtual environment to enter the test/scripts/folder, run Activate.bat, under Linux under the Bin directory, Run command for the source xx/xx/activate Exit command for Deactivate.bat


Specify a different Python environmentvirtualenv -p C:\Python27\python2.exe py2

Quick Configuration

VIRTUALENV-based virtual environment management tools

pip install virtualenvwrapper-win

After the installation is complete, configure the environment variables.


Workonhome

You can then use Workon to display the virtual environment, Mkvirtualenv xx to create a virtual environment, Workon XXX into the virtual environment

Other

    1. When using PIP installation may be prompted to find some files, you can go here to find the WHL file, mainly for Windows user file, downloaded into the virtual environment using PIP installation can be used

    2. MKVIRTUALENV Create other versions of the virtual environment,mkvirtualenv --python=C:\Python27\python2.exe py2scrapy

    3. Linux requires configuration after installing Virtualenvwrapper, find virtualenvwrapper.sh First


Modifying a configuration file


Modify Content


Reload Configuration

Related Article

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.