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
- 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.
- Mkvirtualenv creates virtual environments of other versions,
mkvirtualenv --python=C:\Python27\python2.exe py2scrapy
- After virtualenvwrapper is installed in linux, You need to configure it. find virtualenvwrapper. sh first.
Modify configuration file
Modify content
Reload Configuration