Lots of other threads about similar issues, but none that I could find where quite the same case as mine. So, here goes:
关于类似问题的许多其他线程,但没有一个我能找到与我的情况完全相同的情况。所以,这里是:
Things I did:
我做的事情:
- Ran:
sudo easy_install pip
- Ran:
sudo pip install virtualenv
- Ran:
sudo pip install virtualenvwrapper
冉:sudo easy_install pip
Ran:sudo pip install virtualenv
Ran:sudo pip install virtualenvwrapper
Current State:
-
.bash_profile
export PATH=/usr/local/bin:$PATH export PIP_DOWNLOAD_CACHE=$HOME/.pip/cache export WORKON_HOME=$HOME/.virtualenvs export PIP_VIRTUALENV_BASE=$WORKON_HOME export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python
-
Running
mkvirtualenv test
results in:运行mkvirtualenv测试结果:
New python executable in trunk/bin/python Installing setuptools, pip...done. /usr/bin/python: No module named virtualenvwrapper
-
Manually inspecting '/usr/local/bin' shows that virtualenvwrapper.sh exists
手动检查'/ usr / local / bin'表示virtualenvwrapper.sh存在
- Unlike some other questions I saw about this, I get no message about virtualenvwrapper when I start a new terminal window
- Running 'which python' results in:
/usr/bin/python
.bash_profile export PATH = / usr / local / bin:$ PATH export PIP_DOWNLOAD_CACHE = $ HOME / .pip / cache export WORKON_HOME = $ HOME / .virtualenvs export PIP_VIRTUALENV_BASE = $ WORKON_HOME export VIRTUALENVWRAPPER_PYTHON = / usr / bin / python
与我看到的其他问题不同,当我开始一个新的终端窗口时,我没有得到关于virtualenvwrapper的消息
运行'which python'会导致:/ usr / bin / python
What I've tried:
我尝试过的:
- Inspecting my path to make sure it looks like it is supposed to
- Reinstalling pip, then using the reinstalled pip to reinstall virtualenv and virtualenvwrapper
检查我的路径,确保它看起来像是应该的
重新安装pip,然后使用重新安装的pip重新安装virtualenv和virtualenvwrapper
Any help getting this working would be very much appreciated.
任何帮助实现这项工作将非常感谢。
8 个解决方案
#1
64
I've managed to get this working after having the same problem you've described here by editing my ~/.bash_profile and adding this:
通过编辑我的〜/ .bash_profile并添加以下内容,我已经成功解决了这个问题。
export WORKON_HOME=$HOME/code/.virtualenvs
export PROJECT_HOME=$HOME/code
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
source /usr/local/bin/virtualenvwrapper.sh
Save, close.
then:
$ source ~/.bash_profile
and:
$ mkvirtualenv test
#2
20
I had the same problem setting up virtualenvwrapper on ubuntu.
我在ubuntu上设置virtualenvwrapper时遇到了同样的问题。
I had installed virtualenv, virtualenvwrapper using pip which installed these modules in the site package of python3.5. How did I find that out?
我使用pip安装了virtualenv,virtualenvwrapper,它在python3.5的站点包中安装了这些模块。我是怎么发现的?
Open your terminal and type
打开终端并输入
$ pip --version
pip 9.0.1 from /home/clyton/.virtualenvs/test1/lib/python3.5/site-packages (python 3.5)
来自/home/clyton/.virtualenvs/test1/lib/python3.5/site-packages(python 3.5)的pip 9.0.1
Then I checked the variable VIRTUALENVWRAPPER_PYTHON
whose value was /usr/bin/python. On your terminal and type
然后我检查了变量VIRTUALENVWRAPPER_PYTHON,其值为/ usr / bin / python。在您的终端上并输入
$ ls -l $VIRTUALENVWRAPPER_PYTHON
lrwxrwxrwx 1 root root 9 Dec 10 2015 **/usr/bin/python -> python2.7**
As you can see this variable is pointing to python2.7 and you may have installed virtualenv in a different python site package.
正如您所看到的,此变量指向python2.7,您可能已在不同的python站点包中安装了virtualenv。
So to fix this problem, just add the below line in your bashrc
所以要解决这个问题,只需在你的bashrc中添加以下行
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.5
NOTE: Set the above value to the python version with which virtualenv was installed. In my case it was python3.5 so I have set that value. How to find out the python version used to install virtualenv? Again type pip --version
in the terminal.
注意:将以上值设置为安装virtualenv的python版本。在我的情况下它是python3.5所以我设置了该值。如何找出用于安装virtualenv的python版本?再次在终端输入pip --version。
Then open a new shell session and try mkvirtualenv again. This time it should work.
然后打开一个新的shell会话并再次尝试mkvirtualenv。这一次它应该工作。
#3
11
If you take a look at the virtualenvwrapper.sh script, you will find these lines:
如果你看一下virtualenvwrapper.sh脚本,你会发现这些行:
# Locate the global Python where virtualenvwrapper is installed.
if [ "$VIRTUALENVWRAPPER_PYTHON" = "" ]
then
VIRTUALENVWRAPPER_PYTHON="$(command \which python)"
fi
If you don't manually export VIRTUALENVWRAPPER
appropriately for your version of python, it will assume the system default where you don't have the virtualenvwrapper package installed.
如果您没有为您的python版本手动导出VIRTUALENVWRAPPER,它将假定您没有安装virtualenvwrapper软件包的系统默认值。
I fixed this like so:
我这样解决了这个问题:
echo "export VIRTUALENVWRAPPER_PYTHON=$(which python3.6)" >> ~/.zshrc
This is all documented on the official website here.
这一切都记录在官方网站上。
#4
3
try installing virtualenv and virtualenvwrapper with pip2 install virtualenv virtualenvwrapper
. it seems like pip install virtualenv and it's wrapper to python 3 as it's default
尝试使用pip2 install virtualenv virtualenvwrapper安装virtualenv和virtualenvwrapper。它似乎是pip install virtualenv,它是python 3的包装,因为它是默认的
#5
2
Try to uninstall your virtualenv
and virtualenvwrapper
and install it again using pip
(check if you symlink your pip or assigned an alias on it for other version) in version 2.7 (I think).
尝试卸载你的virtualenv和virtualenvwrapper并使用pip再次安装它(检查你是否符号链接你的pip或为其他版本分配了别名)(我认为)。
I encountered the same error and I just did this and solved my problem.
我遇到了同样的错误,我刚刚做了这个并解决了我的问题。
I using Ubuntu machine.
我用的是Ubuntu机器。
I hope this help.
我希望这有帮助。
#6
1
In my case, adding this line into my .zshrc file did the trick,
在我的情况下,将此行添加到我的.zshrc文件中就可以了,
export VIRTUALENVWRAPPER_PYTHON=/usr/local/Cellar/python/2.7.13/bin/python2.7
remember to source ~/.zshrc to update the change to your current terminal.
记得使用〜/ .zshrc来更新当前终端的更改。
#7
1
Got this error after recently (summer 2017) updating Homebrew and python. The issue in my case was that Homebrew no longer overwrites the system python and I didn't have virtualenv
and virtualenvwrapper
installed for the system python.
最近(2017年夏天)更新Homebrew和python后出现此错误。我的问题是Homebrew不再覆盖系统python,我没有为系统python安装virtualenv和virtualenvwrapper。
The solution in my case was to add the following to ~/.bash_profile
(or ~/.zshrc
):
我的解决方案是将以下内容添加到〜/ .bash_profile(或〜/ .zshrc):
export PATH="$(brew --prefix)/opt/python/libexec/bin:$PATH"
export PATH =“$(brew --prefix)/ opt / python / libexec / bin:$ PATH”
This made python
point to the brew version of python and also gave me pip
back. This version of python
had virtualenv
and virtualenvwrapper
installed so the error no longer appeared. See the caveats section under brew info python
and https://github.com/Homebrew/homebrew-core/issues/15746 for more information
这使python指向了python的brew版本,也让我回头。这个版本的python安装了virtualenv和virtualenvwrapper,因此错误不再出现。有关详细信息,请参阅brew info python和https://github.com/Homebrew/homebrew-core/issues/15746下的警告部分。
#8
0
I don't know if it's relevant to anyone but I got this error while editing ~/.zshrc
while virtualenv being active. So I had to deactivate
and then rmvirtualenv env_name
to remove the errors. And then I recreated the env: mkvirtaulenv env_name
and workon env_name
and this time I got no errors.
我不知道它是否与任何人相关,但是当virtualenv处于活动状态时编辑〜/ .zshrc时出现此错误。所以我不得不停用,然后rmvirtualenv env_name删除错误。然后我重新创建了env:mkvirtaulenv env_name和workon env_name,这次我没有错误。
Hope it helps someone.
希望它可以帮到某人。
#1
64
I've managed to get this working after having the same problem you've described here by editing my ~/.bash_profile and adding this:
通过编辑我的〜/ .bash_profile并添加以下内容,我已经成功解决了这个问题。
export WORKON_HOME=$HOME/code/.virtualenvs
export PROJECT_HOME=$HOME/code
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
source /usr/local/bin/virtualenvwrapper.sh
Save, close.
then:
$ source ~/.bash_profile
and:
$ mkvirtualenv test
#2
20
I had the same problem setting up virtualenvwrapper on ubuntu.
我在ubuntu上设置virtualenvwrapper时遇到了同样的问题。
I had installed virtualenv, virtualenvwrapper using pip which installed these modules in the site package of python3.5. How did I find that out?
我使用pip安装了virtualenv,virtualenvwrapper,它在python3.5的站点包中安装了这些模块。我是怎么发现的?
Open your terminal and type
打开终端并输入
$ pip --version
pip 9.0.1 from /home/clyton/.virtualenvs/test1/lib/python3.5/site-packages (python 3.5)
来自/home/clyton/.virtualenvs/test1/lib/python3.5/site-packages(python 3.5)的pip 9.0.1
Then I checked the variable VIRTUALENVWRAPPER_PYTHON
whose value was /usr/bin/python. On your terminal and type
然后我检查了变量VIRTUALENVWRAPPER_PYTHON,其值为/ usr / bin / python。在您的终端上并输入
$ ls -l $VIRTUALENVWRAPPER_PYTHON
lrwxrwxrwx 1 root root 9 Dec 10 2015 **/usr/bin/python -> python2.7**
As you can see this variable is pointing to python2.7 and you may have installed virtualenv in a different python site package.
正如您所看到的,此变量指向python2.7,您可能已在不同的python站点包中安装了virtualenv。
So to fix this problem, just add the below line in your bashrc
所以要解决这个问题,只需在你的bashrc中添加以下行
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.5
NOTE: Set the above value to the python version with which virtualenv was installed. In my case it was python3.5 so I have set that value. How to find out the python version used to install virtualenv? Again type pip --version
in the terminal.
注意:将以上值设置为安装virtualenv的python版本。在我的情况下它是python3.5所以我设置了该值。如何找出用于安装virtualenv的python版本?再次在终端输入pip --version。
Then open a new shell session and try mkvirtualenv again. This time it should work.
然后打开一个新的shell会话并再次尝试mkvirtualenv。这一次它应该工作。
#3
11
If you take a look at the virtualenvwrapper.sh script, you will find these lines:
如果你看一下virtualenvwrapper.sh脚本,你会发现这些行:
# Locate the global Python where virtualenvwrapper is installed.
if [ "$VIRTUALENVWRAPPER_PYTHON" = "" ]
then
VIRTUALENVWRAPPER_PYTHON="$(command \which python)"
fi
If you don't manually export VIRTUALENVWRAPPER
appropriately for your version of python, it will assume the system default where you don't have the virtualenvwrapper package installed.
如果您没有为您的python版本手动导出VIRTUALENVWRAPPER,它将假定您没有安装virtualenvwrapper软件包的系统默认值。
I fixed this like so:
我这样解决了这个问题:
echo "export VIRTUALENVWRAPPER_PYTHON=$(which python3.6)" >> ~/.zshrc
This is all documented on the official website here.
这一切都记录在官方网站上。
#4
3
try installing virtualenv and virtualenvwrapper with pip2 install virtualenv virtualenvwrapper
. it seems like pip install virtualenv and it's wrapper to python 3 as it's default
尝试使用pip2 install virtualenv virtualenvwrapper安装virtualenv和virtualenvwrapper。它似乎是pip install virtualenv,它是python 3的包装,因为它是默认的
#5
2
Try to uninstall your virtualenv
and virtualenvwrapper
and install it again using pip
(check if you symlink your pip or assigned an alias on it for other version) in version 2.7 (I think).
尝试卸载你的virtualenv和virtualenvwrapper并使用pip再次安装它(检查你是否符号链接你的pip或为其他版本分配了别名)(我认为)。
I encountered the same error and I just did this and solved my problem.
我遇到了同样的错误,我刚刚做了这个并解决了我的问题。
I using Ubuntu machine.
我用的是Ubuntu机器。
I hope this help.
我希望这有帮助。
#6
1
In my case, adding this line into my .zshrc file did the trick,
在我的情况下,将此行添加到我的.zshrc文件中就可以了,
export VIRTUALENVWRAPPER_PYTHON=/usr/local/Cellar/python/2.7.13/bin/python2.7
remember to source ~/.zshrc to update the change to your current terminal.
记得使用〜/ .zshrc来更新当前终端的更改。
#7
1
Got this error after recently (summer 2017) updating Homebrew and python. The issue in my case was that Homebrew no longer overwrites the system python and I didn't have virtualenv
and virtualenvwrapper
installed for the system python.
最近(2017年夏天)更新Homebrew和python后出现此错误。我的问题是Homebrew不再覆盖系统python,我没有为系统python安装virtualenv和virtualenvwrapper。
The solution in my case was to add the following to ~/.bash_profile
(or ~/.zshrc
):
我的解决方案是将以下内容添加到〜/ .bash_profile(或〜/ .zshrc):
export PATH="$(brew --prefix)/opt/python/libexec/bin:$PATH"
export PATH =“$(brew --prefix)/ opt / python / libexec / bin:$ PATH”
This made python
point to the brew version of python and also gave me pip
back. This version of python
had virtualenv
and virtualenvwrapper
installed so the error no longer appeared. See the caveats section under brew info python
and https://github.com/Homebrew/homebrew-core/issues/15746 for more information
这使python指向了python的brew版本,也让我回头。这个版本的python安装了virtualenv和virtualenvwrapper,因此错误不再出现。有关详细信息,请参阅brew info python和https://github.com/Homebrew/homebrew-core/issues/15746下的警告部分。
#8
0
I don't know if it's relevant to anyone but I got this error while editing ~/.zshrc
while virtualenv being active. So I had to deactivate
and then rmvirtualenv env_name
to remove the errors. And then I recreated the env: mkvirtaulenv env_name
and workon env_name
and this time I got no errors.
我不知道它是否与任何人相关,但是当virtualenv处于活动状态时编辑〜/ .zshrc时出现此错误。所以我不得不停用,然后rmvirtualenv env_name删除错误。然后我重新创建了env:mkvirtaulenv env_name和workon env_name,这次我没有错误。
Hope it helps someone.
希望它可以帮到某人。