关于解决安装virtualenv 和virtualenvwrapper的一些报错

问题1

Traceback (most recent call last):
  File "", line 1, in
AttributeError: module 'virtualenv' has no attribute 'main'
解决:vi /usr/bin/virtualenv

修改 首行/usr/bin/python 为/usr/bin/python2或者3

 

问题2

[nie@localhost ~]$ source /usr/local/python3/bin/virtualenvwrapper.sh
/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.
 

解决:vi ~/bashrc

加以下内容 路径根据自己实际情况而定,特别强调VIRTUALENVWRAPPER_PYTHON=/usr/local/python3/bin/python3这个不能用软连接,要用python的真是安装地址

说明:pyenvs 这个文件夹是自己创建的用了存放所有的虚拟环境

 

export VIRTUALENVWRAPPER_PYTHON=/usr/local/python3/bin/python3
export WORKON_HOME=/home/nie/pyenvs
source /usr/local/python3/bin/virtualenvwrapper.sh

 

问题3

执行 source /usr/local/python3/bin/virtualenvwrapper.sh报错 找不到这个文件

解决:whereis virtualenvwrapper.sh 找到绝对位置加到命令里,如果找不到 可以用 find 命令

[nie@localhost pyenvs]$ sudo find / -name virtualenvwrapper.sh
[sudo] password for nie: 
/usr/local/python3/bin/virtualenvwrapper.sh

你可能感兴趣的:(python,linux,centos)