使用 pyenv + pipx 安装 virtualenvwrapper 时出现问题
Problem while installing virtualenvwrapper with pyenv + pipx
我正在尝试在我的 macOS(使用 zsh)中安装 virtualenvwrapper
(而不是 pyenv-virtualenvwrapper
)。我正在使用 pyenv
管理多个 python 版本,并使用 pipx
安装 CLI 东西。
我正在使用 Python 3.8.1
$ pyenv versions
system
2.7.17
* 3.8.1 (set by /Users/my_user/.pyenv/version)
我用 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
我在 .zshrc
中插入了以下几行:
export WORKON_HOME=$HOME/.virtualenvs
source /Users/my_user/.local/pipx/venvs/virtualenvwrapper/bin/virtualenvwrapper.sh
export PIP_VIRTUALENV_BASE=$WORKON_HOME
但是当我启动 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.
$
我该如何解决这个问题?
已修复指定特定 VIRTUALENVWRAPPER_PYTHON
而不指向 shim
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
我正在尝试在我的 macOS(使用 zsh)中安装 virtualenvwrapper
(而不是 pyenv-virtualenvwrapper
)。我正在使用 pyenv
管理多个 python 版本,并使用 pipx
安装 CLI 东西。
我正在使用 Python 3.8.1
$ pyenv versions
system
2.7.17
* 3.8.1 (set by /Users/my_user/.pyenv/version)
我用 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
我在 .zshrc
中插入了以下几行:
export WORKON_HOME=$HOME/.virtualenvs
source /Users/my_user/.local/pipx/venvs/virtualenvwrapper/bin/virtualenvwrapper.sh
export PIP_VIRTUALENV_BASE=$WORKON_HOME
但是当我启动 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.
$
我该如何解决这个问题?
已修复指定特定 VIRTUALENVWRAPPER_PYTHON
而不指向 shim
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