标签: virtualenvwrapper

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

在 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)

python bash virtualenv virtualenvwrapper 16.04

17
推荐指数
3
解决办法
3万
查看次数

Virtualenv 将 env 安装到 local/bin 而不是 bin

问题:

bin我用virtualenvwrappervirtualenv在后台使用)生成的虚拟环境的目录位于子文件夹中,local而不是导致全面损坏(主要virtualenvwrappervscode目前)。基本上,这些工具期望解释器位于<envname>/bin而不是位于<envname>/local/bin.

信息:

我已经做了一些研究并发现了以下内容:

  • Ubuntu 22.04 中进行了更改,现在posix_local在模块中使用sysconfig而不是作为posix_prefix默认方案,这在此处进行了解释
  • Virtualenv 在某个时候引入了一个 Python 2 补丁,该补丁将位置更改binlocal/bin虚拟环境内部以响应前缀,这是在这个问题posix_local中提出的,并产生了这个补丁,该补丁应该修复这个错误

系统:

  • Ubuntu 22.04 LTS x86_64
  • python3 - 3.10.4-0ubuntu2
  • python3-virtualenv - 20.13.0+ds-2
  • 虚拟环境包装器==4.8.4

问题:

  • 如何virtualenv再次安装我的环境<envname>/bin,忽略posix_local选项?
  • 修复此问题的原因是否仍然适用于 Python 3?(我必须承认,我一开始并没有真正理解为什么需要这个补丁。)

python3 virtualenv virtualenvwrapper 22.04

10
推荐指数
1
解决办法
5282
查看次数

彻底卸载 virtualenv 和 virtualenvwrapper

因为我没有在这个时候使用他们,我试图卸载virtualenvvirtualenvwrapper通过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)

software-center virtualenv virtualenvwrapper

7
推荐指数
1
解决办法
2万
查看次数

Virtualenv permission denied

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 …

permissions bashrc virtualenv virtualenvwrapper

7
推荐指数
1
解决办法
7539
查看次数