When I compiled the test.py(very simple Python file) in the Sublime Text or CodeRunner, I got an error: /bin/bash: python: command not found. Then I entered python test.pyin the application βTerminalβ, it worked. Later I downloaded Pycharm and compiled the file again, it works too!
So, I assume that there is some kind of path parameter or something else that was set incorrectly. I searched for quite a while on the Internet, but to no avail. Please help or try to give some ideas on how to solve the problem.
Here are a few details:
I tried pasting #! /usr/bin/pythonat the beginning of the file test.pybut did not use
echo "$PATH"Terminal output/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 found several versions of Python in my macbook: 2.6, 2.7, 3.2, 3.3, 3.5. In the folder /System/Library/Frameworks/Python.framework/VersionsI found 2.6, 2.7. In the folder /Library/Frameworks/Python.framework/VersionsI found 3.2, 3.3, 3.5.
I myself solved the problem and posted the answer below
source
share