flo*_*urr 6 python virtualenv virtualenvwrapper pyenv
我正在尝试在我的 macOS 中安装virtualenvwrapper(不是pyenv-virtualenvwrapper)(使用 zsh)。我用来pyenv管理多个 python 版本并pipx安装 CLI 东西。
我正在使用Python 3.8.1
$ pyenv versions
system
2.7.17
* 3.8.1 (set by /Users/my_user/.pyenv/version)
Run Code Online (Sandbox Code Playgroud)
我用 pipx 安装了 virtualenvwrapper
$ pipx install virtualenvwrapper
$ pipx list
venvs are in /Users/my_user/.local/pipx/venvs
apps are exposed on your $PATH at /Users/my_user/.local/bin
package sshuttle 0.78.5, Python 3.8.1
- sshuttle
package virtualenv 20.0.15, Python 3.8.1
- virtualenv
package virtualenvwrapper 4.8.4, Python 3.8.1
- virtualenvwrapper.sh
- virtualenvwrapper_lazy.sh
Run Code Online (Sandbox Code Playgroud)
我插入了.zshrc以下几行:
export WORKON_HOME=$HOME/.virtualenvs
source /Users/my_user/.local/pipx/venvs/virtualenvwrapper/bin/virtualenvwrapper.sh
export PIP_VIRTUALENV_BASE=$WORKON_HOME
Run Code Online (Sandbox Code Playgroud)
但是当我启动 shell 时,出现以下错误:
/Users/my_user/.pyenv/versions/3.8.1/bin/python: Error while finding module specification for 'virtualenvwrapper.hook_loader' (ModuleNotFoundError: No module named 'virtualenvwrapper')
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=/Users/my_user/.pyenv/shims/python and that PATH is
set properly.
$
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
flo*_*urr 12
修复了指定特定VIRTUALENVWRAPPER_PYTHON而不指向垫片的问题
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/Users/my_user/.local/pipx/venvs/virtualenvwrapper/bin/python3.8
source /Users/my_user/.local/pipx/venvs/virtualenvwrapper/bin/virtualenvwrapper.sh
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1127 次 |
| 最近记录: |