0

I installed Python 2.7.12 with Brew on my Mac (Mac OS Sierra 10.12.1) and set my Path to /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin. Everything just works fine: python --version in the terminal gives me 2.7.12.

For coding I installed Coderunner2. In Preferences > Advanced I get the exact same PATH: Screenshot

But when I run

#!/usr/local/bin/python import platform print platform.python_version()

in Coderunner, it gives me 2.7.10.

What am I missing here? Why isn't Coderunner using Python 2.7.12?

  • It seems that your Python code is not properly formated. For example i think the shebang line is incomplete. I try to make the edit myself but SO don't let me. – yeiniel Nov 12 '16 at 01:00
  • I updatet the code (see above). Still it returns 2.7.10 (the Mac OS Version) in the console). – Papierschnellboot Nov 12 '16 at 09:22

1 Answers1

0

your script's interpreter isn't a valid interpreter (it's a directory on your host, right?) so you must be running that script like:

python check_version.py 

which is running whatever python is in your path first. you should verify which python you're actually running from the command line as show below.

i also run a Homebrew python install (2.7.11), but MacOS comes with its own python installed by default (2.7.10). my homebrew install puts the newer version in /usr/local/bin/python whereas the default MacOS version is in /usr/bin/python, as show below. for your script, make sure your interpreter points to the correct python version you want:

wintermute:~ 19:22:47 melgart$ which python
/usr/local/bin/python
wintermute:~ 19:22:52 melgart$ /usr/local/bin/python -V
Python 2.7.11
wintermute:~ 19:22:58 melgart$ ls -l /usr/bin/python
-rwxr-xr-x  1 root  wheel  66848 Sep 13 20:56 /usr/bin/python*
wintermute:~ 19:23:09 melgart$ /usr/bin/python -V
Python 2.7.10
wintermute:~ 19:23:13 melgart$
matias elgart
  • 1,123
  • 12
  • 18