workon|mkvirtualenv报错
virtualenvwrapper 安装了,报错如下:
/usr/bin/python: 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=/usr/bin/python and that PATH is
set properly.
意思是说virtualenvwrapper需要调用virtualenvwrapper.hook_loader,如果不成功,请检查virtualenvwrapper的安装在哪个python版本下,并设置环境变量VIRTUALENVWRAPPER_PYTHON=成功安装意思是说virtualenvwrapper需要调用virtualenvwrapper的版本
/Library/Frameworks/Python.framework/Versions/3.8/bin/virtualenv
iMac-52:~ apple$ which python3.8
/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8
vim .bash_profile
以下配置仅供参考
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/apple/google-cloud-sdk/path.bash.inc' ]; then . '/Users/apple/google-cloud-sdk/path.bash.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/Users/apple/google-cloud-sdk/completion.bash.inc' ]; then . '/Users/apple/google-cloud-sdk/completion.bash.inc'; fi
alias vim='/Applications/MacVim.app/Contents/bin/vim'
export MAVEN_HOME=/Users/apple/apache-maven-3.6.0
export GO111MODULE=on
export GOPROXY=https://goproxy.io
export GOROOT="/usr/local/go"
export GOPATH="/Users/apple/go"
export WORKON_HOME="/Users/apple/.virtualenvs"
export VIRTUALENVWRAPPER_PYTHON="/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8"
export PATH=$VIRTUALENVWRAPPER_PYTHON:$WORKON_HOME:$GOROOT/bin:/usr/bin/g++:$GOPATH/bin:/Users/apple/desktop/go:/usr/local/mysql/bin:$GOPATH/bin:$PATH:$MAVEN_HOME/bin
export PATH="/usr/local/opt/ruby/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"
alias pip3="/Library/Frameworks/Python.framework/Versions/3.8/bin/pip3.8"
##
# Your previous /Users/apple/.bash_profile file was backed up as /Users/apple/.bash_profile.macports-saved_2019-09-20_at_10:39:31
##
# MacPorts Installer addition on 2019-09-20_at_10:39:31: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.
上面测试OK,但是第二天打开电脑workon
又报错了
最后解决办法: https://medium.com/@suubidavid/virtualenvwrapper-module-not-found-error-solution-5f3672deb6e2
最终配置:
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/apple/google-cloud-sdk/path.bash.inc' ]; then . '/Users/apple/google-cloud-sdk/path.bash.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/Users/apple/google-cloud-sdk/completion.bash.inc' ]; then . '/Users/apple/google-cloud-sdk/completion.bash.inc'; fi
alias vim='/Applications/MacVim.app/Contents/bin/vim'
export MAVEN_HOME=/Users/apple/apache-maven-3.6.0
export GO111MODULE=on
export GOPROXY=https://goproxy.io
export GOROOT="/usr/local/go"
export GOPATH="/Users/apple/go"
export WORKON_HOME="/Users/apple/.virtualenvs"
export VIRTUALENVWRAPPER_VIRTUALENV="/usr/local/bin/virtualenv"
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='— no-site-packages'
export PROJECT_HOME=$HOME/Desktop/scott
export VIRTUALENVWRAPPER_PYTHON="/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8"
export PATH=$PROJECT_HOME:$VIRTUALENVWRAPPER_PYTHON:$WORKON_HOME:$GOROOT/bin:/usr/bin/g++:$GOPATH/bin:/Users/apple/desktop/go:/usr/local/mysql/bin:$GOPATH/bin:$PATH:$MAVEN_HOME/bin
export PATH="/usr/local/opt/ruby/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"
alias pip3="/Library/Frameworks/Python.framework/Versions/3.8/bin/pip3.8"
alias python="/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8"
source `which virtualenvwrapper.sh`
#参考 https://medium.com/@suubidavid/virtualenvwrapper-module-not-found-error-solution-5f3672deb6e2
# Your previous /Users/apple/.bash_profile file was backed up as /Users/apple/.bash_profile.macports-saved_2019-09-20_at_10:39:31
##
# MacPorts Installer addition on 2019-09-20_at_10:39:31: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.