我正在尝试在我的macOS上安装virtualenvwrapper(而不是pyenv-virtualenvwrapper),使用zsh。 我使用pyenv来管理多个python版本,并使用pipx安装CLI工具。
我正在使用Python 3.8.1。
如何解决这个问题?
我正在使用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.
$
如何解决这个问题?