source ~/.bashrc virtualenvwrapper 出错

我在阿里云上安装 virtualenvwrapper  配置完bashrc  ,  source .bashrc 的时候出现如下错误:

root@iZ2zedvcgvpdsfdys825esZ:~# source ~/.bashrc
/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.
root@iZ2zedvcgvpdsfdys825esZ:~# pip install virtualenv
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
ImportError: cannot import name main

这里是我 vim .bashrc 后配置的内容(这个配置是错的):-----------------------------

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
# . /etc/bash_completion
#fi

-------在最后面添加的---------------------------------------- 

export WORKON_HOME=$HOME/.virtualenvs

export PROJECT_HOME=$HOME/workspace

source /usr/local/bin/virtualenvwrapper.sh

分析问题:

python3 -V 

python3.5.2

我看了下我的python3 在哪里:

root@iZ2zedvcgvpdsfdys825esZ:~# which python3
/usr/bin/python3

原来是python3 的路径问题,

解决问题:

root@iZ2zedvcgvpdsfdys825esZ:~# vim ~/.bashrc

在 打开的bashrc末尾添加如下内容:-----------------------

# Setting PATH for Python 3.5

PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.5

export WORKON_HOME=$HOME/.virtualenvs

export PROJECT_HOME=$HOME/workspace

source /usr/local/bin/virtualenvwrapper.sh

esc :x 退出

最后:

source ~/.bashrc
virtualenvwrapper.user_scripts creating /root/.virtualenvs/premkproject
virtualenvwrapper.user_scripts creating /root/.virtualenvs/postmkproject
virtualenvwrapper.user_scripts creating /root/.virtualenvs/initialize
virtualenvwrapper.user_scripts creating /root/.virtualenvs/premkvirtualenv
virtualenvwrapper.user_scripts creating /root/.virtualenvs/postmkvirtualenv
virtualenvwrapper.user_scripts creating /root/.virtualenvs/prermvirtualenv
virtualenvwrapper.user_scripts creating /root/.virtualenvs/postrmvirtualenv
virtualenvwrapper.user_scripts creating /root/.virtualenvs/predeactivate
virtualenvwrapper.user_scripts creating /root/.virtualenvs/postdeactivate
virtualenvwrapper.user_scripts creating /root/.virtualenvs/preactivate
virtualenvwrapper.user_scripts creating /root/.virtualenvs/postactivate
virtualenvwrapper.user_scripts creating /root/.virtualenvs/get_env_details
root@iZ2zedvcgvpdsfdys825esZ:~# 

这样是不是就OK了呀!嘻嘻。

猜你喜欢

转载自www.cnblogs.com/--A--/p/9807503.html