When I compiled test.py
(a very simple Python file) in Sublime Text or CodeRunner, I got the error:/bin/bash: python: command not found
. Then I input python test.py
in the Terminal app, it worked. Later I downloaded Pycharm and compiled the file again, it worked too!
So I assume there is some kind of path setting or something else that was not set correctly. I've searched for quite a long time on the internet but no use. Please help or try to give some ideas how to solve the problem.
Here are some details:
I've tried inserting
#! /usr/bin/python
at the top oftest.py
file but no useThe output of
echo "$PATH"
in Terminal is/usr/local/sbin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/Users/chenyang/Downloads/android-sdk-macosx/platform-tools
I've found several versions of Python in my macbook :2.6, 2.7, 3.2, 3.3, 3.5. Under the folder
/System/Library/Frameworks/Python.framework/Versions
I found 2.6, 2.7. Under the folder/Library/Frameworks/Python.framework/Versions
I found 3.2, 3,3, 3.5.
I've solved the problem myself and post the answer below