ubuntu under virtual environment configuration python3

Related to the installation package

sudo PIP3 install virtualenv # virtual environment package
 sudo PIP3 install virtualenvwrapper # virtual environment management pack

Create a virtual environment directory

sudo $HOME/.virtualenvs

Modify the configuration file

sudo gedit ~/.bashrc

In the file add

WORKON_HOME the HOME = $ Export / .virtualenvs 
Source / usr / local / bin / virtualenvwrapper. SH 
// virtualenvwrapper.sh path can be obtained by the command sudo find / -name virtualenvwrapper.sh

 The file to take effect

source ~/.bashrc

 If there are mistakes

/usr/bin/python: No module named virtualenvwrapper
virtualenvwrapper.sh: There was a problem running the initialization hooks.

If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is
set properly.

 The reason is that the python2 and installation python3 my ubuntu, here python2 use to configure the default virtual environment, and we are beginning to install in python3 virtualenvwrapper , it will report an error without this module.

Solution, adding environment variables in the configuration file in ~ / .bashrc

VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3

Then the configuration file to take effect

source ~/.bashrc

I would not have the error.

 Related Commands

Creating the environment, mkvirtualenv [virtual environment name], such as:

mkvirtualenv  py3test

Enter the virtual environment, workon [virtual environment name], such as

workon py3test

Exit Virtual Environment

deactivate

 

Guess you like

Origin www.cnblogs.com/miaoning/p/11568369.html