问题1:
➜ ~ source ~/.bash_profile
/usr/local/bin/python3: 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=/usr/local/bin/python3 and that PATH is
set properly.
问题2:
/usr/local/bin/python3.7: 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=/usr/local/bin/python3.7 and that PATH is
set properly.
问题3:
学着网上的信息,配置如下:
vim ~/.bash_profile
export WORKON_HOME=$HOME/.virtualenvs
#export PROJECT_HOME=$HOME/workspace
export VIRTUALENVWRAPPER_PYTHON=/usr/local/lib/python3.7
source /usr/local/bin/virtualenvwrapper.sh
source ~/.bash_profile
然后刷缓存,提示:
virtualenvwrapper_run_hook:12: permission denied: /usr/local/lib/python3.7
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/lib/python3.7 and that PATH is
set properly.
我最想说的就是问题3,网上都没答案!!!!就好像网上都没有人遇到过相关问题,下面我就写对应的解决配置,如果有一样不幸的朋友可以参考,真实有效!
先说一下,我的文档所在目录和前提:
1)mac刚买的时候就自带了2.7的python , 然后我就自己装了python3;
2)我是直接pip3 install virtualenv安装virtualenv的;然后就都是默认路径,下面说下我被安装的路径:
要配置要先找全和搞清楚以下文件的路径!!!!!很重要,不然就是各种报错
2.1)/usr/local/bin/virtualenvwrapper.sh #我一开始一直按网上说的配这个文件在的地址,然后因为mac对usr文件的权限控制,一直提示权限问题!烦了我2天这个问题
2.2)/usr/local/lib/python3.7/site-packages/virtualenvwrapper/__pycache__/hook_loader.cpython-37.pyc
因为一直被提示:If Python could not import the module virtualenvwrapper.hook_loader,所以我就去找hook_loader文件,哈哈果然被我找到了;
2.3)最后具体配置:
#这个我就不说了
export WORKON_HOME=$HOME/.virtualenvs
#下面这个配不配都可以,为什么要配VIRTUALENVWRAPPER_PYTHON搞这么久我的感悟就是为了定位到下一行配置的source 执行要的文件而已;包括我去改virtualenvwrapper.sh的python内容( VIRTUALENVWRAPPER_PYTHON="$(command \which python)")目的都是一样的
#export VIRTUALENVWRAPPER_PYTHON=/usr/local/lib/python3.7
#下面这个是关键,我一开始配成:/usr/local/bin/virtualenvwrapper.sh,然后开始各种权限报错,头疼的一批,还好提示信息救了我,我找到了hook_loader.cpython-37.pyc文件,然后把这个路径配在下面,终于不报错了!!!!,是一个文件夹,不是.sh文件,也不知道其他人配那个.sh文件所在路径,怎么就不会有权限问题,反正我搞了半天 ,最后反正配成以下内容就可以了
source /usr/local/lib/python3.7/site-packages/virtualenvwrapper
最后讲一下,后面执行语句虽然报权限问题,但是不用管他,都是能执行成功的!!
例如:
➜ ~ workon py2env #(py2env是已经存在的虚拟环境,下面报错不用管,虽然报错了,但是执行成功了,你可以看到你已经进入了)
virtualenvwrapper_run_hook:12: permission denied: /usr/local/lib/python3.7
virtualenvwrapper_run_hook:12: permission denied: /usr/local/lib/python3.7
以上就是全部内容,希望对你有所帮助谢谢~