Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python "bad interpreter" ERROR

All 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

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

Prior to this, I used Python installed with HomeBrew, but this path does not appear to be a brew file path anyway.

Bottom line... My file path is messed up somewhere other than in my .bash_profile and I have no idea where to look to fix it.


Also note that I set up my other computer with the same exact .bash_profile and python installations and it works perfectly...

Both are running Mac Yosemite.

Thanks in advance!

like image 546
Dex Avatar asked Apr 20 '15 00:04

Dex


People also ask

How do you fix a bad interpreter?

To fix the error in the Windows operating system, open the bash script file in the Notepad++ editor and then go to the preferences tab via the settings menu as below. Close the window after choosing Unix/OSX as the format. Afterwards, save and close the file.

What is bad interpreter error?

bad interpreter no such file or directory. It is caused by the presence of the Window return character (^M) that is ending the line. This mostly occurs when copying and pasting an unknown source file into the operating system. The window return can be removed by simply executing the command: sed -i -e 's/r$//' filename ...

What is #!/ Usr bin python?

By specifying #!/usr/bin/python you specify exactly which interpreter will be used to run the script on a particular system. This is the hardcoded path to the python interpreter for that particular system. The advantage of this line is that you can use a specific python version to run your code.


1 Answers

Ok, I was able to fix the problem with a fresh install of virtualenv. I assume that is where the path issue was located (somewhere in the installation of virtualenv).

like image 169
Dex Avatar answered Sep 29 '22 04:09

Dex