Mac OS X / bin / bash: python command: not found in some IDE

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

+4
source share
2 answers

Thanks to everyone who helps. I myself solved the problem.

I always used zsh instead of bash. After upgrading CodeRunner to the latest version, the application uses bash by default. Therefore, I just need to go to the menu "Settings"> "Advanced" and uncheck the box to call bash in the login mode when I run the code to solve the problem.

Sublime Text3 : fooobar.com/questions/1648949/...

0

, PATH, ~/.profile, ~/.bashrc, ~/.bash_profile .. Mac OS X/ Finder. , , Finder, PATH , .

Mac OS X , Finder. Mac OS X ~/.MacOSX/environment.plist, . OS X launchctl , , launchctl ( ).

, :

launchctl setenv <variable-name> <variable-value>

. , , . , , :

launchctl setenv PATH "$PATH"

... , PATH .

. :

+4

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


All Articles