Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

macos - Python asks for older paths on mac after deleting duplicate python installation

I am having the below error after a clean installation of python via brew install python. The link belongs to a previous python installation which I deleted manually.

$ virtualenv ENV
python: posix_spawn: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No such file or directory

I am using MacOS 10.7.3 and I installed virtualenv via pip:

$ sudo /usr/local/share/python/pip install virtualenv
 Downloading/unpacking virtualenv
 Downloading virtualenv-1.7.1.2.tar.gz (2.1Mb): 2.1Mb downloaded
 Running setup.py egg_info for package virtualenv

 warning: no previously-included files matching '*.*' found under directory 'docs/_templates'
 Installing collected packages: virtualenv
 Running setup.py install for virtualenv

 warning: no previously-included files matching '*.*' found under directory 'docs/_templates'
 Installing virtualenv script to /usr/local/share/python
 Successfully installed virtualenv
 Cleaning up...
$ virtualenv ENV
 python: posix_spawn: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No such file or directory

How can I fix this?

Edit : I reinstalled MacOSx and now returned back to my previous status that made me delete the preinstalled python.

$ which python 
/Library/Frameworks/Python.framework/Versions/2.7/bin/python 
$ which pip /usr/local/bin/pip $ sudo pip install virtualenv
Downloading/unpacking virtualenv 
Downloading virtualenv-1.7.1.2.tar.gz (2.1Mb): 2.1Mb downloaded
Running setup.py egg_info for package virtualenv

warning: no previously-included files matching '*.*' found under directory 'docs/_templates'
Installing collected packages: virtualenv
Running setup.py install for virtualenv

warning: no previously-included files matching '*.*' found under directory 'docs/_templates'
Installing virtualenv script to /usr/local/bin
Successfully installed virtualenv
Cleaning up...


$ python virtualenv.py ENV
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/??MacOS/Python: can't open file 'virtualenv.py': [Errno 2] No such file or directory

The virtualenv.py is located at /Library/Python/2.7/site-packages/virtualenv.py and /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/py2app/recipes/virtualenv.py but somehow python misses all.

Why there is so much mess? How should I proceed to fix this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I had the very same situation after done stupid thing of deleting whole /System/Library/Frameworks/Python.framework/ what results in error:

python: posix_spawn: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No such file or directory

I managed to restore it, because I had a earlier copy of my whole disk, and just by copy-pasting the whole Python.framework directory back.

I don't know how much it is system dependent, but if somebody would like to try do that the same way instead of reinstalling whole OS X, the whole Python.framework zipped from me is here: http://andilabs.com/Python.framework.zip


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...