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

Problem analysis of virtualenv isolating Python environment

編輯:Python

Catalog

virtualenv Introduce

virtualenv application

virtualenv Introduce

virtualenv Provides isolated for applications Python Running environment , It solves the problem of multi version conflict between different applications .
virtualenv Put the system Python Make a copy to virtualenv Environment , Command source venv/bin/activate Enter a virtualenv Environmental time ,virtualenv The relevant environment variables will be modified , Let the order python and pip All point to the current virtualenv Environmental Science .
install virtualenv

virtualenv application pip3 install virtualenv

Create project

mkdir myprojectcd myproject/

Create a new python Environmental Science

virtualenv --no-site-packages py_new# Parameters :--no-site-packages Already installed on the system Python All third-party packages in the environment will not be copied

New Python The environment is placed in the current directory py_new Catalog .
With py_new Environmental Science , It can be used source Enter the environment :

source py_new/bin/activate

pip All installed packages are installed to py_new In this environment , System Python The environment is not affected in any way

pip install pandas

Exit the current py_new Environmental Science

deactivate

after pip or python All in the system Python Execution in environment

Add :virtualenv establish “ Isolation ” Of Python Running environment

Windows install mkvirtualenv

pip install virtualenvpip install virtualenvwrapper  

New virtual python Environmental Science :

1. establish python Project directory :
2. Create an independent Python Running environment , Name it redis:

virtualenv  redis

3. Activate the environment :( or workon)

cd D:\05_python_virtualenv\redis\Scripts.\activate

Notice that the command prompt has changed , There is one (venv) Prefix , Indicates that the current environment is one called venv Of Python Environmental Science

4. Exit the current venv Environmental Science :deactivate

There is an error :virtualenv: error: unrecognized arguments: --no-site-packages
Use virtualenv --version, See version greater than 20, This parameter is the default , It can be cancelled –no-site-packages

virtualenvwrapper --helprmvirtualenv redis

stay win Computer environment variables - System variables : newly added :WORKON_HOME, by D:\05_python_virtualenv

This is about virtualenv Isolation Python This is where the article on environment is introduced , More about virtualenv Isolation Python Please search the previous articles of the software development network or continue to browse the relevant articles below. I hope you will support the software development network in the future !



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