Virtualenv enables coexistence of multiple versions of Python, virtualenvpython

Source: Internet
Author: User
Tags virtualenv

Virtualenv enables coexistence of multiple versions of Python, virtualenvpython

Virtualenv creates an environment with its own installation directory. This environment does not share libraries with other virtual environments, allowing you to conveniently manage python versions and manage python libraries. It mainly solves the problem of environment conflicts between different projects.

Tips

Some sdks may encounter downloading errors when downloading. If you configure a domestic image, the chances of errors will be greatly reduced. It is easy to use the image source. Just specify it with-I:

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

For example, you need to install the django Environment


Use virtualenv

To uninstall django, you can usepip uninstall django

VirtualenvAfter installation, you need to create an independent virtualenv environment. For details, refer to the help command:


Basic commands

Common parameters include:

-P: Specifies a version of the python environment. It is usually used when multiple python versions are installed in your system. By default, virtualenv preferentially selects its host python environment, that is, if it is installed in that python version, the default version will be used as the default python isolation environment.
-- No-site-packages: the python installation package in the system environment is not used. That is, the installation package in the real python environment cannot be used in the isolation package. The current version is the default one.
-- System-site-packages: opposite to the above, enabling the isolated environment to access the python installation package of the system Environment
-- Distribute: copy the branch of a python environment. By default, basic modules such as setup, pip, and wheel are installed.

Virtualenv test: Use this command to create a Python environment in the specified path. By default, it is consistent with the system environment. To enter the virtual environment, enter the test/Scripts/folder and run activate. bat in the bin directory in Linux, run the command source xx/activate to exit the command deactivate. bat


Specify other Python Environmentsvirtualenv -p C:\Python27\python2.exe py2

Quick Configuration

Virtualenv-based Virtual Environment Management Tool

pip install virtualenvwrapper-win

Configure environment variables after installation ,.


WORKONHOME

Then you can use workon to display the virtual environment. mkvirtualenv xx creates a virtual environment and workon xxx enters the virtual environment.

Others

  1. When installing pip, you may be prompted to find some files. You can find the whl file here, mainly for Windows User Files. After downloading the file, you can use pip to install it in the virtual environment.
  2. Mkvirtualenv creates virtual environments of other versions,mkvirtualenv --python=C:\Python27\python2.exe py2scrapy
  3. After virtualenvwrapper is installed in linux, You need to configure it. find virtualenvwrapper. sh first.


Modify 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.