指向正确的 python 版本时出错:virtualenvwrapper.sh [英] Error with pointing to correct python version: virtualenvwrapper.sh

查看:25
本文介绍了指向正确的 python 版本时出错:virtualenvwrapper.sh的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我启动终端时出现此错误:

I get this error when I boot up terminal:

Last login: Thu Apr  9 19:49:08 on ttys001
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/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=/Library/Frameworks/Python.framework/Versions/2.7/bin/python and that PATH is
set properly.
dhcp-128-189-78-23:~ user_me$ 

我需要将我的虚拟环境指向"我正在使用的 python 版本.

I need to "point" my virtual environment to the version of python I'm using.

我该怎么做?

推荐答案

我遇到了同样的问题,更新我的路径没有任何帮助,设置 VIRTUALENVWRAPPER_PYTHON 和 VIRTUALENVWRAPPER_VIRTUALENV 也没有帮助.这是因为我在运行我的 python 版本时看到了这种奇怪的行为:

I had the same exact issue and updating my path didn't help anything, nor did setting VIRTUALENVWRAPPER_PYTHON and VIRTUALENVWRAPPER_VIRTUALENV. This is because I was seeing this strange behavior when running my version of python:

$ /usr/local/bin/python
Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.executable
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python

通过使用 brew 卸载 python、使用 brew 重新安装 python 并强制它覆盖/usr/local/bin 中的现有符号链接,我能够解决所有问题.

I was able to fix everything by uninstalling python with brew, reinstalling python with brew, and forcing it to overwrite existing symlinks in /usr/local/bin.

brew uninstall --force python
brew install python
brew link --overwrite python
brew linkapps python
pip install --upgrade pip setuptools
sudo pip uninstall virtualenv
pip install virtualenv
sudo pip uninstall virtualenvwrapper
pip install virtualenvwrapper

希望您在六个月前遇到这个问题时能够解决这个问题.我想发布我的解决方案,以防其他人遇到同样的问题并且无法通过设置他们的路径和环境变量来解决它.

Hopefully you were able to get past this issue when you encountered it six months ago. I wanted to post my solution in case others run in to the same issue and cannot solve it by setting their paths and env variables.

这篇关于指向正确的 python 版本时出错:virtualenvwrapper.sh的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆