问题描述
我按照以下步骤设置了 virtualenv + virtualenvwrapper:
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
到目前为止它工作正常,但我重新启动了 shell,然后我尝试了 workon venv
,现在它说:command not found
So far it was working fine but I restarted the shell and then I tried workon venv
and now it says: command not found
推荐答案
原因是你重启了shell.
The reason is because you restarted the shell.
如果您希望它适用于每个 shell,您需要将这些添加到您的 ~/.bashrc
文件中:
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
添加后,您需要 source ~/.bashrc
以便更改生效.您会发现您可以访问每个新 shell 中的 virtualenvwrapper
设施.
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.
这篇关于Virtualenv - 找不到工作命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!