Python "bad interpreter" ERROR

Everything seems to work just fine for both python 2 and 3:

$ which Python /Library/Frameworks/Python.framework/Versions/2.7/bin/python $ python --version Python 2.7.9 $ python2 Python 2.7.9 (v2.7.9:648dcafa7e5f, Dec 10 2014, 10:10:46) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. $ python3 Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 23 2015, 02:52:03) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. 

My .bash_profile settings are as follows:

 PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}" export PATH PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}" export PATH 

Problem:

 $ virtualenv My_Env -bash: /usr/local/bin/virtualenv: /usr/local/opt/python3/bin/python3.4: bad interpreter: No such file or directory 

The path above does not exist. I downloaded my python packages directly from the python site and installed using the default settings.

Before that, I used Python installed with HomeBrew, but this path is still not the brew file path.

Bottom line ... My file path is confused somewhere other than my .bash_profile, and I have no idea where to fix it.


Also note that I configured my other computer with the exact same settings .bash_profile and python and it works fine ...

Both are running Mac Yosemite.

Thanks in advance!

+13
source share
4 answers

Ok, I was able to fix the problem with the new virtualenv installation. I assume that the path was found there (somewhere in the virtualenv installation).

+11
source

My problem was as simple as having spaces in the directory at the top of venv/bin/pip which meant that the path was inside quotes. As soon as I made sure that it was not in the directory with spaces, and removed the quotes, it worked.

eg. #!"/Users/Tomm/MY PROJECT/venv/bin/python" should be changed to #!/Users/Tomm/MY-PROJECT/venv/bin/python

+6
source

You can check the β€œactivate” file in your virtual virtual disk folder and see what is written on line 42, and then you can manually install it, bearing in mind that all executable files in this bin folder are complex encoded for the first line of shebang.

You will also need to change them. Or just move the folder to the right place for the current time task, otherwise you may need a virtual moving tool or just reinstall it.

+1
source

Reinstalling virtualenv should fix this problem. I also went through the same error, and reinstalling with pip solved this for me.

+1
source

Source: https://habr.com/ru/post/985475/


All Articles