mkvirtualenv—没有站点包命令获取“找不到命令”

2024-05-14 03:48:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经安装了virtualenv和virtualenvwrapper,但在尝试设置应用程序时,输入mkvirtualenv --no-site-packages会得到以下错误:

-bash: mkvirtualenv: command not found

我不知道如何解决这个问题。作为一个初学者,我很感激你的帮助。


Tags: nobash应用程序virtualenvpackages错误sitenot
2条回答

您需要启用virtualenvwrapper,如its docs中所述。

Shell Startup File

Add three lines to your shell startup file (.bashrc, .profile, etc.) to set the location where the virtual environments should live, the location of your development project directories, and the location of the script installed with this package:

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

After editing it, reload the startup file (e.g., run source ~/.bashrc).

这实际上可能有一点不同,这取决于你如何安装它。如果你用apt在Ubuntu上安装它,virtualenvwrapper函数实际上会被滚动到bash完成文件中(弄清楚这很有趣!)。

export WORKON_HOME=$HOME/.virtualenvs 
export PROJECT_HOME=$HOME/Devel
possible_scripts='/usr/local/bin/virtualenvwrapper.sh /etc/bash_completion.d/virtualenvwrapper'
for script in $possible_scripts; do
  [[ -f $script ]] && source $script
done

相关问题 更多 >