在 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.
Run Code Online (Sandbox Code Playgroud)
脚本位置是,
$ sudo find / -name virtualenvwrapper.sh
[sudo] password for john:
/usr/local/bin/virtualenvwrapper.sh
Run Code Online (Sandbox Code Playgroud)
我的内容.bashrc
是,
export WORKON_HOME=/home/john/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
export PIP_VIRTUALENV_BASE=/home/john/.virtualenvs
Run Code Online (Sandbox Code Playgroud)
这是我的 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 …
Run Code Online (Sandbox Code Playgroud) 问题:
bin
我用virtualenvwrapper
(virtualenv
在后台使用)生成的虚拟环境的目录位于子文件夹中,local
而不是导致全面损坏(主要virtualenvwrapper
是vscode
目前)。基本上,这些工具期望解释器位于<envname>/bin
而不是位于<envname>/local/bin
.
信息:
我已经做了一些研究并发现了以下内容:
posix_local
在模块中使用sysconfig
而不是作为posix_prefix
默认方案,这在此处进行了解释bin
为local/bin
虚拟环境内部以响应前缀,这是在这个问题posix_local
中提出的,并产生了这个补丁,该补丁应该修复这个错误系统:
问题:
virtualenv
再次安装我的环境<envname>/bin
,忽略posix_local
选项?因为我没有在这个时候使用他们,我试图卸载virtualenv
并virtualenvwrapper
通过Ubuntu软件中心。现在,每当我打开控制台时,都会收到以下错误消息:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named virtualenvwrapper.hook_loader
virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is set properly.
Run Code Online (Sandbox Code Playgroud)
此外,该目录~/.virtualenvs/
仍然存在。
我怎样才能让我的系统恢复到安装virtualenv
和之前的干净和功能状态virtualenvwrapper
?
更新
按照建议,我检查了以下文件中virtualenv
每个文件的出现是否有负面结果:
~/.bashrc
~/.profile
/etc/profile
/etc/profile.d/*
/etc/environment
Run Code Online (Sandbox Code Playgroud) After a lot of struggle with virtualenv/virtualenvwrapper I decided to remove all virtualenvs and re-install the packages.
root> su myuser
myuser> sudo pip install virtualenv
myuser> sudo pip install virtualenvwrapper
Run Code Online (Sandbox Code Playgroud)
I proceeded to add this to my unix users .bashrc file.
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python2.7
source /usr/local/bin/virtualenvwrapper.sh
Run Code Online (Sandbox Code Playgroud)
When I source .bashrc I get about 20 error lines ending with IOError: [Errno 13] Permission denied: '/root/.virtualenvs/premkproject'
. I'm running out of ideas...
I have done my homework and tried every suggested …