source ~/.bashrc virtualenvwrapper 出错

Posted --a--

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了source ~/.bashrc virtualenvwrapper 出错相关的知识,希望对你有一定的参考价值。

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

[email protected]:~# 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.
[email protected]:~# 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 在哪里:

[email protected]:~# which python3
/usr/bin/python3

原来是python3 的路径问题,

 

解决问题:

[email protected]:~# 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
[email protected]:~# 

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

 
































以上是关于source ~/.bashrc virtualenvwrapper 出错的主要内容,如果未能解决你的问题,请参考以下文章

source ~/.bashrc virtualenvwrapper 出错

linux下.bashrc为啥每次打开终端都要source一下才有效,如何才能永远生效?

ubuntu 18.04 source .bashrc 不生效

source ~/.bashrc 无法执行

source ~/.bashrc 什么意思

远程登陆ubantu服务器 .bashrc文件每次打开终端都需要source的问题