When attempting to run pipenv
& mkdocs
on a mac I'm getting error:
bash: /usr/local/bin/pipenv: /usr/local/opt/python@2/bin/python2.7: bad interpreter: No such file or directory
$ pipenv
bash: /usr/local/bin/pipenv: /usr/local/opt/python@2/bin/python2.7: bad interpreter: No such file or directory
$ mkdocs
bash: /usr/local/bin/mkdocs: /usr/local/opt/python@2/bin/python2.7: bad interpreter: No such file or directory
$
Some additional information in case its useful, Command python
links to what I think is the default python installation provided on a Mac:
$ which python
/usr/local/bin/python
$ ls -l $(which python)
lrwxr-xr-x 1 jamiet admin 15 Nov 12 12:58 /usr/local/bin/python -> /usr/bin/python
$ which python3
/usr/local/bin/python3
$ ls -l $(which python3)
lrwxr-xr-x 1 jamiet admin 34 May 2 2019 /usr/local/bin/python3 -> ../Cellar/python/3.7.3/bin/python3
$ python --version
Python 2.7.10
that may or may not be useful.
I found a useful thread where someone had experienced a similar issue: pip installation /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory and I've followed some of the suggestions on there:
brew link --overwrite python
I had used home-brew to install 2.7 on OS X 10.10 and the new install was missing the sym links. I ran
brew link --overwrite python
as mentioned in How to symlink python in Homebrew? and it solved the problem.
I believe python2 WAS initially installed on this machine using homebrew so I tried that, but no luck:
$ brew link --overwrite python
Warning: Already linked: /usr/local/Cellar/python/3.7.3
To relink: brew unlink python && brew link python
I have not (yet) tried the suggestion there (brew unlink python && brew link python
) as I wanted to try a few other things and get some advice from here first
symlink to correct location
Tried to create a symlink to my known python2 interpreter at the location that pipenv
/mkdocs
are expecting it, but it didn't work:
$ /usr/local/bin/python --version
Python 2.7.10
$ ln -s /usr/local/bin/python /usr/local/opt/python@2/bin/python2.7
ln: failed to create symbolic link '/usr/local/opt/python@2/bin/python2.7': No such file or directory
Note that if I try a slightly different command (i.e. just a different path) then the command succeeds without error:
$ ln -s /usr/local/bin/python /usr/local/opt/python/bin/python2.7
$ ls -l /usr/local/opt/python/bin/python2.7
lrwxr-xr-x 1 jamiet admin 21 Jan 16 16:06 /usr/local/opt/python/bin/python2.7 -> /usr/local/bin/python
but that doesn't help me because pipenv
/mkdocs
are expecting the interpreter to be at /usr/local/opt/python@2/bin/python2.7 so I removed the symlink
$ rm /usr/local/opt/python/bin/python2.7
Can anyone suggest a way forward?