Installing Python virtual environment (Linux)

 

My Ubuntu 18.04 pre-installed python 3.6, but not installed pip, so the first installation:

apt-get install python-pip

 

1. Install the virtual environment needed to package:

pip install virtualenv
pip install virtualenvwrapper

Wherein the second packet is the encapsulated packet to the first command, the command because it is too complicated, difficult to operate.

 

Although the installation is complete, but still can not use the command, you must first do the following:

Create a directory to store the virtual environment:

mkdir $HOME/.virtualenvs

 

Setting environment variables, add ~ / .bashrc file following two lines:

export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh

 

With the source command to make the changes just takes effect immediately:

source ~/.bashrc

 

Virtualenv related to this command is ready to use.

 

2. Create a virtual environment

mkvirtualenv your_name

 

3. Start using virtual environments

workon your_name

 

4. Exit the virtual environment

deactivate

 

5. Delete the virtual environment

rmvirtualenv your_name

 

6. Review which is currently used Python

which python

 

Guess you like

Origin www.cnblogs.com/zoneofmine/p/11073679.html