Virtualenv - workon command not found

痞子三分冷 提交于 2020-01-12 01:37:30

问题


I followed these steps to set up virtualenv + virtualenvwrapper:

$ sudo apt-get install python3-pip

$ sudo pip3 install virtualenv
$ sudo pip3 install virtualenvwrapper

$ mkdir ~/.virtualenvs

$ export WORKON_HOME=~/.virtualenvs

$ VIRTUALENVWRAPPER_PYTHON='/usr/bin/python3'

$ source /usr/local/bin/virtualenvwrapper.sh

$ mkvirtualenv venv
$ virtualenv venv

So far it was working fine but I restarted the shell and then I tried workon venv and now it says: command not found


回答1:


So far it was working fine but I restarted the shell

The reason is because you restarted the shell.

If you want this to work with each shell, you'll need to add these to your ~/.bashrc file:

export WORKON_HOME=~/.virtualenvs
VIRTUALENVWRAPPER_PYTHON='/usr/bin/python3'
source /usr/local/bin/virtualenvwrapper.sh

After adding this, you'll want to source ~/.bashrc so the changes take effect. You'll find that you have access to virtualenvwrapper facilities in each new shell.




回答2:


You need to add commands

export WORKON_HOME=~/.virtualenvs
VIRTUALENVWRAPPER_PYTHON='/usr/bin/python3'
source /usr/local/bin/virtualenvwrapper.sh

to your ~/.bashrc file. So that whenever you start shell these commands are loaded automatically.

For the reference.



来源:https://stackoverflow.com/questions/34611394/virtualenv-workon-command-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!