2

I've tried everything I can but now I need help! I've hit the limit of what I do understand.

My error:

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

My take is that virtualenv doesn't know where python is. Is this the case? How can I fix this?

System is Mac OSX 10.9.4

I have used brew to install python 2.7.8.1. - Python 2.7*something* was on there but I removed it. I can't remember exactly what I did to do that however. Sorry. I am new to macs. - This new python instance sits here: /usr/local/Cellar/python/2.7.8_1/ - The /usr/local/bin/python file when I readlink /usr/local/bin/python it points to the above

.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'

Paths:

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

Python seems to work but path looks busy

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']

Any help appreciated!

Thanks,

Andy


This is going badly..... Help! Not least because I have messed up the links, I think there is a problem with these links

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

I thought I had it. I changed the links as follows. But it's still screwed.

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$

I'd better stop now before I do any more damage.

I changed /usr/bin/python to point to /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

No the error has evolved to the below:

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
Andrew Taylor
  • 41
  • 1
  • 5
  • why you are using `lsvirtualenv` ? – Mazdak Aug 30 '14 at 17:05
  • I did have it installed previously. Adding nothing above I realise. I had an environment I wanted but I can live without it. All this started because I wanted the same python version as heroku's official 2.7 which wasn't the case – Andrew Taylor Aug 30 '14 at 17:13
  • see this link http://stackoverflow.com/questions/25024874/how-would-i-run-lsvirtualenv-or-any-of-the-other-virtualenvwrapper-functions-via – Mazdak Aug 30 '14 at 17:22
  • Hi, I’m afraid I don’t follow can you help me put it steps? The “which virtualenvwrapper.sh” statement gives me /usr/local/bin/virtualenvwrapper.sh - Isn’t that what I should see? I have uninstalled and re-installed using pip install virtualenvwrapper --upgrade to no avail. virtualenvwrapper.sh looks right – Andrew Taylor Aug 30 '14 at 17:57
  • i have not much experience `with virtualenv warpper` but much with `virtualenv` now you write virtualenvwrapper.sh looks right so whats your problem now ? – Mazdak Aug 30 '14 at 18:05
  • I was trying to determine what you were helping me with with that link. If we forget virtualenvwrapper, I still see this: virtualenv ENV -bash: /usr/local/bin/virtualenv: /usr/bin/python: bad interpreter: No such file or directory – Andrew Taylor Aug 30 '14 at 18:10
  • sorry i haven't any idea ! maybe its because of your python version ! – Mazdak Aug 30 '14 at 18:17
  • Is there an issue with these lines perhaps: andytmac:~ admin$ readlink /usr/bin/python /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python andytmac:~ admin$ readlink /System/Library/Frameworks/Python.framework/Versions/Current /System/Library/Frameworks/Python.framework/Versions/2.7 – Andrew Taylor Aug 30 '14 at 18:19
  • This happens when you upgrade your version of Python and virtualenv is pointing to the old version. – Burhan Khalid Aug 31 '14 at 10:55

1 Answers1

1

Resolved as follows:

  1. System restore by downloading and re-installing Maverics (using the automated apple startup tool)
  2. Following the advice here: Can't pip install virtualenv in OS X 10.8 with brewed python 2.7 and here: http://www.lowindata.com/2013/installing-scientific-python-on-mac-os-x/
  3. My virtualenv was in a different location to that specified in page (2), so bash_profile should contain source /usr/local/bin/virtualenvwrapper.sh instead of: source /usr/local/share/python/virtualenvwrapper.sh
Community
  • 1
  • 1
Andrew Taylor
  • 41
  • 1
  • 5