更新后 python 和 virtualenvwrapper 的问题:没有名为 virtualenvwrapper 的模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29486113/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
problems with python and virtualenvwrapper after updating: No module named virtualenvwrapper
提问by mthecreator
I run python 2.7.6 with virtualenv, virtualenvwrapper under ubuntu 14.04.
now i have installed python 2.7.9 from source. the new python interpreter is now located under /usr/local/bin
but it seems the old interpreter is also located under /usr/bin
.
我在 ubuntu 14.04 下使用 virtualenv、virtualenvwrapper 运行 python 2.7.6。现在我已经从源代码安装了 python 2.7.9。新的Python解释器现在位于下/usr/local/bin
,但它似乎老解释也位于下/usr/bin
。
if I run python shell it shows up python2.7.9. but if I use mkvirtualenv venv
I am getting the following message.
如果我运行 python shell,它会显示 python2.7.9。但如果我使用,mkvirtualenv venv
我会收到以下消息。
New python executable in venv/bin/python
Installing setuptools, pip...done.
Blockquote /usr/local/bin/python: No module named virtualenvwrapper
venv/bin/python 中的新 python 可执行文件
安装 setuptools,pip...完成。
Blockquote /usr/local/bin/python: 没有名为 virtualenvwrapper 的模块
old .bashrc
(with working configuration using python 2.7.6 interpreter)
旧的.bashrc
(使用 python 2.7.6 解释器的工作配置)
# virtualenv-wrappper path
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh
new .bashrc
(with failure configuration)
新的.bashrc
(带有故障配置)
# virtualenv-wrappper path
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh
with the new .baschrc
I type in source .bashrc
and get the following output.
使用新的.baschrc
I 输入source .bashrc
并获得以下输出。
/usr/local/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/local/bin/python and that PATH is set properly.
/usr/local/bin/python:没有名为 virtualenvwrapper 的模块 virtualenvwrapper.sh:运行初始化挂钩时出现问题。
如果 Python 无法导入模块 virtualenvwrapper.hook_loader,请检查是否已为 VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python 安装了 virtualenvwrapper,并且 PATH 设置是否正确。
And I have also tried which -a python
:
我也试过which -a python
:
output:
输出:
/usr/local/bin/python
/usr/bin/python
I want to use python 2.7.9 with virtualenv and virtualenvwrapper. so what I have to do to get this running ?
我想将 python 2.7.9 与 virtualenv 和 virtualenvwrapper 一起使用。所以我必须做些什么才能让它运行?
采纳答案by Railslide
You need to install them under python 2.7.9 by specifying the path to correct version of pip to be used
您需要通过指定要使用的正确 pip 版本的路径将它们安装在 python 2.7.9 下
/usr/local/bin/pip install virtualenv virtualenvwrapper
otherwise, when running pip install
the sytem will use the default one (i.e. the one located at /usr/bin/pip
)
否则,在运行pip install
系统时将使用默认的(即位于/usr/bin/pip
)
回答by Sudipta Basak
If you have modified your virtualenvwrapper
to point to python3
, like I do:
如果您修改virtualenvwrapper
了指向python3
,就像我一样:
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
then make sure you install the virtualenv
and virtualenvwrapper
using:
然后确保安装virtualenv
并virtualenvwrapper
使用:
sudo /usr/local/bin/pip3 install virtualenv virtualenvwrapper
回答by likaiguo.happy
source /usr/local/bin/virtualenvwrapper_lazy.sh
source /usr/local/bin/virtualenvwrapper_lazy.sh
when use pyenv:
使用 pyenv 时:
export PYENV_ROOT="${HOME}/.pyenv"
if [ -d "${PYENV_ROOT}" ]; then
export PATH="${PYENV_ROOT}/bin:${PATH}"
eval "$(pyenv init -)"
fi
export PATH
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
#important
source /usr/local/bin/virtualenvwrapper_lazy.sh