I don\'t know what\'s the deal but I am stuck following some stackoverflow solutions which gets nowhere. Can you please help me on this?
Monas-MacBook-Pro:
To simplify to operation, we can use the below command to reinstall version 2:
brew install python@2
Then on my mac, it looks as below:
▶ python -V
Python 2.7.10
▶ python2 -V
Python 2.7.14
▶ python3 -V
Python 3.6.5
▶ pip2 -V
pip 9.0.3 from /usr/local/lib/python2.7/site-packages (python 2.7)
▶ pip3 -V
pip 9.0.3 from /usr/local/lib/python3.6/site-packages (python 3.6)
▶ pip --version
pip 9.0.3 from /usr/local/lib/python2.7/site-packages (python 2.7)
I had the same issue, virtualenv was pointing to an old python path. Fixing the path resolved the issue:
$ virtualenv -p python2.7 env
-bash: /usr/local/bin/virtualenv: /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory
$ which python2.7
/opt/local/bin/python2.7
# needed to change to correct python path
$ head /usr/local/bin/virtualenv
#!/usr/local/opt/python/bin/python2.7 <<<< REMOVED THIS LINE
#!/opt/local/bin/python2.7 <<<<< REPLACED WITH CORRECT PATH
# now it works:
$ virtualenv -p python2.7 env
Running virtualenv with interpreter /opt/local/bin/python2.7
New python executable in env/bin/python
Installing setuptools, pip...done.
I got same problem. If I run brew link --overwrite python2
. There was still zsh: /usr/local/bin//fab: bad interpreter: /usr/local/opt/python/bin/python2.7: no such file or directory
.
cd /usr/local/opt/
mv python2 python
Solved it! Now we can use python2 version fabric.
=== 2018/07/25 updated
There is convinient way to use python2 version fab when your os python linked to python3. .sh
for your command.
# fab python2
cd /usr/local/opt
rm python
ln -s python2 python
# use the fab cli
...
# link to python3
cd /usr/local/opt
rm python
ln -s python3 python
Hope this helps.
I had similar issue. Basically pip was looking in a wrong path (old installation path) or python. The following solution worked for me:
which python
)/usr/local/bin/pip2.7
and /usr/local/bin/pip
). The line should state the correct path to the python path. In my case, didn't. I corrected it and now it works fine.I made the same error using sudo for my installation. (oops)
brew install python
brew linkapps python
brew link --overwrite python
This brought everything back to normal.
I had the same issue. I have both Python 2.7 & 3.6 installed. Python 2.7 had virtualenv
working, but after installing Python3, virtualenv kept looking for version 2.7 and couldn't find it.
Doing pip install virtualenv
installed the Python3 version of virtualenv.
Then, for each command, if I want to use Python2, I would use virtualenv --python=python2.7 somecommand