VIRTUALENV bash:/ usr / local / bin / virtualenv:/ usr / bin / python:bad interpreter:没有这样的文件或目录

时间:2014-08-30 14:58:57

标签: python python-2.7 osx-mavericks virtualenv virtualenvwrapper

我尽我所能,但现在我需要帮助!我达到了我理解的极限。

我的错误:

andytmac:~ admin$ lsvirtualenv
andytmac:~ admin$ mkvirtualenv test
-bash: /usr/local/bin/virtualenv: /usr/bin/python: bad interpreter: No such file or directory

我认为virtualenv不知道python在哪里。是这样的吗?我怎样才能解决这个问题?

系统是Mac OSX 10.9.4

我用brew来安装python 2.7.8.1。   - Python 2.7 *东西*在那里,但我删除它。我不记得我到底做了什么。抱歉。我是mac的新手。   - 这个新的python实例位于:/usr/local/Cellar/python/2.7.8_1/   - 当我读取链接/ usr / local / bin / python时它指向上面的/usr/local/bin/python文件

的.bash_profile:

export PROJECT_HOME=$HOME/Projects
export PATH=$PATH:/usr/local/bin
export PATH=$PATH:/usr/local/bin/psql
export PYTHONPATH=$PYTHONPATH:/usr/local/bin/python

export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh

alias showhidden='defaults write com.apple.finder AppleShowAllFiles TRUE; killall Finder'
alias hidehidden='defaults write com.apple.finder AppleShowAllFiles FALSE; killall Finder'

路径:

andytmac:~ admin$ cat /etc/paths
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

Python似乎有用,但路径看起来很忙

Python 2.7.8 (default, Aug 24 2014, 21:26:19) 
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.path
['', '/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.49-py2.7.egg', '/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg', '/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-5.4.2-py2.7.egg', '/usr/local/lib/python2.7/site-packages/distribute-0.6.49-py2.7.egg', '/usr/local/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg', '/usr/local/lib/python2.7/site-packages/setuptools-5.4.2-py2.7.egg', '/Users/admin', '/usr/local/Cellar/python/2.7.8_1', '/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/site-packages']

任何帮助表示赞赏!

谢谢,

安迪


这很糟糕.....求助!尤其是因为我搞砸了链接,我认为这些链接存在问题

andytmac:~ admin$ ln -s /usr/bin/python /System/Library/Frameworks/Python.framework/Versions/2.7
ln: /System/Library/Frameworks/Python.framework/Versions/2.7: Permission denied
andytmac:~ admin$ sudo ln -s /usr/bin/python /System/Library/Frameworks/Python.framework/Versions/2.7
Password:
andytmac:~ admin$ readlink /System/Library/Frameworks/Python.framework/Versions/2.7
/usr/bin/python
andytmac:~ admin$ readlink /usr/bin/python
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python
andytmac:~ admin$ sudo ln - s /usr/local/Cellar/python/2.7.8_1/ user/bin/python
ln: user/bin/python: No such file or directory
andytmac:~ admin$ sudo ln - s /usr/local/Cellar/python/2.7.8_1 /usr/bin/python
ln: /usr/bin/python: Too many levels of symbolic links
andytmac:~ admin$ readlink /usr/bin/python
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python
andytmac:~ admin$ sudo ln - s /usr/local/Cellar/python/2.7.8_1 /System/Library/Frameworks/Python.framework/Versions/2.7
ln: /System/Library/Frameworks/Python.framework/Versions/2.7: Too many levels of symbolic links
andytmac:~ admin$ python

我以为我拥有它。我改变了链接如下。但它还是搞砸了。

Andytmac:~ admin$ readlink /System/Library/Frameworks/Python.framework/Versions/Current
/System/Library/Frameworks/Python.framework/Versions/2.7
Andytmac:~ admin$ readlink /System/Library/Frameworks/Python.framework/Versions/2.7
/usr/bin/python
Andytmac:~ admin$ readlink /usr/bin/python
/usr/local/Cellar/python/2.7.8_1
Andytmac:~ admin$ virtualenv ENV
-bash: /usr/local/bin/virtualenv: /usr/bin/python: bad interpreter: Permission denied
Andytmac:~ admin$

在我造成更多伤害之前,我最好先停下来。

我将/ usr / bin / python更改为指向/usr/local/Cellar/python/2.7.8_1/bin python2.7:

Andytmac:~ admin$ readlink /usr/bin/python
/usr/local/Cellar/python/2.7.8_1/bin/python2.7

没有错误演变为以下内容:

Andytmac:~ admin$ lsvirtualenv
Andytmac:~ admin$ mkvirtualenv Test
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 5, in <module>
    from pkg_resources import load_entry_point
  File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 2876, in <module>
  File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 451, in _build_master
  File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 464, in _build_from_requirements
  File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 639, in resolve
pkg_resources.DistributionNotFound: virtualenv==1.10.1

1 个答案:

答案 0 :(得分:1)

解决方法如下:

  1. 通过下载并重新安装Maverics(使用自动Apple启动工具)进行系统还原
  2. 遵循以下建议: Can't pip install virtualenv in OS X 10.8 with brewed python 2.7 和这里: http://www.lowindata.com/2013/installing-scientific-python-on-mac-os-x/
  3. 我的virtualenv与第(2)页中指定的位置不同,因此bash_profile应该包含 来源/usr/local/bin/virtualenvwrapper.sh 代替: 来源/usr/local/share/python/virtualenvwrapper.sh