程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python uses the virtualenvwrapper module to create virtual environments

編輯:Python

One, installation

on Windows

pip install virtualpip install virtualenvwrapper-win

on macOS / Linux

pip install --user virtualenvwrapperecho "source virtualenvwrapper.sh" >> ~/.bashrcsource ~/.bashrc

Second, create a virtual environment

on Windows

Create a virtual environment to the specified directory and modify the twenty-four lines of the E:\python3.7.6\Scripts\mkvirtualenv.bat file as follows:

set "venvwrapper.default_workon_home=E:\python3.7.6\Envs"

mkvirtualenv --python=python3 myenv

on macOS/Linux

mkvirtualenv --python=python3.6 myenv

Three, activate the environment

Set the workon environment variable, operation: environment variable --> system variable --> new: variable name: WORKON_HOME variable value: E:\python3.7.6\Envs

workon lists the virtual environment list

workon [myenv] switch environment

Four, exit the environment

deactivate

Five, delete the environment

rmvirtualenv myenv

Six, other useful instructions

1.pip freeze to view the current installed library version

Create a requirements.txt file that contains a simple list of all packages and their respective versions in the current environment

pip freeze > requirements.txt

2. Keep the deployment the same, install all packages with one click

pip install -r requirements.txt

3. List all environments

lsvirtualenv

4. Navigate to the directory of the currently activated virtual environment, equivalent to the pushd directory

cdvirtualenv

5. Similar to the above, go directly to the site-packages directory

cdsitepackages

6. Display the contents of the site-packages directory

lssitepackages

7. Download through the domestic Tsinghua mirror

pip install pandas -i https://pypi.tuna.tsinghua.edu.cn/simple

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved