1

I'm using the Komodo IDE for Mac 10.10.5 and trying a simple code to run a youtube video via python. Once I save and run the python file, i get the following error:

"/bin/sh: Python-1.py: command not found"

I appreciate any help, thank you!

#!/usr/bin/env python
import webbrowser
webbrowser.open(https://www.youtube.com/watch?v=cLyUcAUMmMY")
Calviar45
  • 11
  • 2
  • 3
    this means, you are most likely doing `Python-1.py` in the command line, instead of `python Python-1.py`. Also, you have an invalid syntax in the URL. – karthikr Sep 29 '15 at 19:01
  • @karthikr: I am not familiar with Mac, but on Unix, you can do exactly that -- call your file and when it has execution rights and the first line contains the interpreter, the file can be executed directly without prefixing with "python". – Juergen Sep 29 '15 at 19:10
  • @karthikr I am using the "Run Command" prompt on the IDE after saving my file, and a new error appeared after including the "python" prefix before my file name "Python-1.py"..."no such file or directory" – Calviar45 Sep 29 '15 at 19:32
  • @Calviar45: When you just try to run "python" without anything else, do you get the same error? I guess, either the python interpreter (called python) is not found (either path unknown or not installed) is not in the search path for programs or when you start python from the Run command, the file "Python-1.py" can not be found because the system uses the path of the python program. In the second case, you must use a full qualified path! – Juergen Sep 29 '15 at 21:19
  • @Juergen I'm sorry, I don't think i know exactly what you mean by running pythong without "anything else". i did try to run a simple helloworld example and encountered the same error. – Calviar45 Sep 29 '15 at 22:04

1 Answers1

0

You have to tell Komodo Run Command that you're executing a Python file (same as in the terminal).

You can use the Komodo interpolation feature:

%(python) %F

That tells Komodo to use the Python2 interpreter configured in your preferences and to run the currently active file in the editor.

Or you can also simply enter the exact command you would normally enter in terminal:

python Python-1.py

NOTE: If you're using Komodo IDE you have the debugger and Debug menu > Run Without Debugging.

th3coop
  • 411
  • 4
  • 11
  • Hey, thank you for your input. I tried using the interpolation feature, and I received an error saying that the file i was trying to run was "Not a directory". The same error occurred using the next command as well – Calviar45 Sep 29 '15 at 22:42
  • You used lower case f, not uppercase F. – th3coop Sep 29 '15 at 22:52
  • I used uppercase F, and i got the same error message unfortunately. Also, my "Run Without Debugging" option is grayed out in my terminal – Calviar45 Sep 29 '15 at 23:01
  • Paste the command you're using here please. It works like a charm for me. Also try `%(python) -V` in Run Command and confirm Komodo has found your Python install. – th3coop Sep 29 '15 at 23:07
  • when I go to Tools > Run Command and the prompt appears, I tried the python Python-1.py as well as "%(python) %F" – Calviar45 Sep 29 '15 at 23:11
  • Ok, i changed my shebang line on the top prior to the code from: #!/usr/bin/env python to #!/usr/bin/env python2 and the code ran. When I used the "-V" it showed that i was using Python 2.7.10. However, I don't understand why in the run prompt I cannot just enter the name of my file and have it run. – Calviar45 Sep 29 '15 at 23:23
  • I believe it's because you have `.py` appended to the file name. The shebang method appears to only work when the file doesn't have an extension. I just tried it in Run Commad and it works great: - file name `file` -contents `#!/usr/bin/env python print("pizza")` - Enter full path of file (aka %F) in Run Command and press enter `pizza` – th3coop Sep 29 '15 at 23:50
  • I got it to work! So, when the Run Command prompt appears, I entered the file name like any other terminal (Example: python Python-1.py) In the same Run command prompt window, there is an "Advanced Options" tab, where I set the "Start In" option to "%D" and set it as my default settings. The code now runs without having to enter the full path for the file, and without having to use the shebang line! – Calviar45 Sep 30 '15 at 19:42