运行初始化挂钩的Python virtualenvwrapper问题


10

在16.04的全新安装中,我尝试通过遵循Gerhard Burger的出色回答来安装virtualenvwrapper 。

配置完后.bashrc,只要打开终端显示

bash: /usr/local/bin/python2.7: No such file or directory
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/local/bin/python2.7 and that PATH is
set properly.

脚本位置是

$ sudo find / -name virtualenvwrapper.sh
[sudo] password for john: 
/usr/local/bin/virtualenvwrapper.sh

我的内容.bashrc

export WORKON_HOME=/home/john/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
export PIP_VIRTUALENV_BASE=/home/john/.virtualenvs

这是我的 pip freeze

cffi==1.5.2
greenlet==0.4.9
pbr==1.10.0
readline==6.2.4.1
six==1.10.0
stevedore==1.15.0
virtualenv==15.0.2
virtualenv-clone==0.2.6
virtualenvwrapper==4.7.1

python解释器的位置,

$ which python
/usr/bin/python

我该如何运作?

谢谢。


欢迎来到AskUbuntu。您可能需要包含指向您所提到的答案的链接:)
Videonauth

@Videonauth谢谢。我只是在清理时删除了链接。抱歉。
2016年

@John My /usr/local/bin确实不包含python2.7,而且我怀疑您的也没有。which python2.7/usr/bin/python2.7,但我还没有弄清楚如何告诉而不是virtualenvwrapper看。/usr/bin/usr/local/bin
edwinksl

@John基于virtualenvwrapper.readthedocs.io/en/latest / ...,您可以添加export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python.bashrc以前source /usr/local/bin/virtualenvwrapper.sh吗?
edwinksl

@edwinksl尝试了一下,但是没有解决。
2016年

Answers:


17

我正在使用Ubuntu服务器16.04,还应该导出安装了virtualenvwrapper的python解释器

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

因为我已经安装了多个python。



1

您可能需要更新您的PYTHONPATH环境变量。在您的.bashrc中,在所有virtualenvwrapper变量之前,添加以下行:

export PYTHONPATH=${PYTHONPATH}:/usr/bin

0

.bashrc变化中

VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3

然后通过以下方式使其在当前shell中起作用

source /usr/local/bin/virtualenvwrapper.sh 

之后,更改 virtualenvwrapper.sh

VIRTUALENVWRAPPER_PYTHON="$(command \which python)"

对此

VIRTUALENVWRAPPER_PYTHON="$(command \which python3)"
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.