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

Create and manage Python virtual environments (ubuntu18.04)

編輯:Python

Different applications often use different versions of modules and packages .

In the virtual environment, we can only install the dependent packages required by the program , The virtual environments are isolated from each other , They don't influence each other .

The way 1. adopt Terminal terminal

  1. python3 -m venv venv1 Create the directory where the virtual environment is located

  2. source venv1/bin/activate Activate the virtual environment

  3. rm -rf venv1 Delete virtual environment venv1

  4. pip list View the installed libraries in the virtual environment

  5. pip install xxx Install third party libraries

  6. deactivate Exit virtual environment

The way 2. adopt pyenv + virtualenv Use

  1. git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv

  2. echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc

  3. source ~/.bashrc

Creating a virtual environment venv2

  1. pyenv virtualenv 3.7.10 venv2

Activate the environment venv2

  1. pyenv activate venv2

  2. Start using the environment

Switch back to the system environment

  1. pyenv deactivate

Delete environment venv2

  1. rm -rf ~/.pyenv/versions/venv2

 

 


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