Raspberry Pi 3b install virtualenv and virtualenvwrapper

Install virtualenv and virtualenvwrapper on Raspberry Pi 3b, find a little pit, record it.
On my Raspberry Pi, both python2.7 and python3.5 exist

 

Install


Run the command:

sudo apt-get install virtualenv
sudo apt-get install virtualenvwrapper

ps: Or use pip3 to install, you must use sudo permissions when installing pip3, otherwise there will be some inexplicable situations.

sudo pip3 install virtualenv virtualenvwrapper



 

Configure virtualenvwrapper

 

~/.bashrcAdd the following command to the end of the join

#export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export WORKON_HOME=$HOME/.virtualenvs
source /usr/share/virtualenvwrapper/virtualenvwrapper.sh

Then run:

source ~/.bashrc

In this way, the installation of virtualenvwrapper is completed
ps:
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
For the coexistence of python2.7 and 3.5, it is necessary to tell virtualenvwrapper a default python. Generally, Linux systems must set this environment variable.
Use apt- Get installation:
But in the Raspberry Pi, after setting this environment variable, when creating a virtual environment, an inexplicable error is reported. Commenting out this line is fine. Very puzzled. Of course we have a way to specify the python version later.
Using pip3 to install, there is no such problem.
 

use

Create an environment

mkvirtualenv env1

mkvirtualenv env2

After the environment is created, it will automatically enter the directory and activate the environment.

Create an environment with the specified python version:

mkvirtualenv -p /usr/bin/python3 py3env

Specify the path of python directly after the -p parameter
Note:
In other articles, including the versions I use for other Linux, just enter
mkvirtualenv -p python3 py3env directly
, but in the Raspberry Pi system, it will only go to the current directory Looking for python3, if it can't find it, it will report an error, and it will not look in the system environment variables. The full path must be added, I don't know why.

switch environment

workon env1

workon env2

List existing environments

workon

Exit the environment

deactivate

delete environment

rmvirtualenv

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324399187&siteId=291194637