Installation Python3 virtual environment (VirtualEnv) Tutorial on Mac

 

If you have installed pip3, then execute the command to install virtualenv environment

pip3 install virtualenv

Installation detects whether the installation was successful version

virtualenv --version

Create a new directory

Mac:~ michael$ mkdir myproject
Mac:~ michael$ cd myproject/
Mac:myproject michael$

Creating a stand-alone Python runtime environment, namedvenv,参数--no-site-packages,表示已经安装到系统Python环境中的所有第三方包都不会复制过来,这样,我们就得到了一个不带任何第三方包的“干净”的Python运行环境。

Mac:myproject michael$ virtualenv --no-site-packages venv
Using base prefix '/usr/local/.../Python.framework/Versions/3.4'
New python executable in venv/bin/python3.4
Also creating executable in venv/bin/python
Installing setuptools, pip, wheel...done.

With sourceaccess to the environment

Mac:myproject michael$ source venv/bin/activate
(venv)Mac:myproject michael$

Exit the current venvenvironment

(venv)Mac:myproject michael$ deactivate 
Mac:myproject michael$ 

 

 

 

reference:

https://www.jianshu.com/p/d37662e6ef34

https://www.liaoxuefeng.com/wiki/1016959663602400/1019273143120480

 

Guess you like

Origin www.cnblogs.com/sea-stream/p/11427449.html