Forums

no such Python interpreter

Hi guys,

I'm getting the following error when I try to run a script from the scheduler ...

/usr/bin/env python: no such Python interpreter

It runs fine from a console - is this a bug in the scheduler?

Dan

Yes it is, it's our fault, we have some code that tries to be clever and check on what interpreter you're using, and it gets confused by the /usr/bin/env formulation. (if you're curious, you can check it out, it's at /bin/run_scheduled_task.py)

switch to #!/usr/bin/python and it will work fine...

/usr/bin/env python: no such Python interpreter
2016-01-29 14:07:09 -- Completed task, took 0.00 seconds, return code was 0.

/usr/bin/python python: no such Python interpreter
2016-01-31 14:07:09 -- Completed task, took 0.00 seconds, return code was 0.

Doesn't work here, however no problem from command line.

Anything else I can try?

Sorry, just "#!/usr/bin/python", not "#!/usr/bin/python python"

Oups, that's better :)

Thx.

Hello, I have a similar problem.

The error message I see in the task log is:

/usr/bin/env python2.7: no such Python interpreter
2017-11-23 15:49:06 -- Completed task, took 2.00 seconds, return code was 0.

My script has the following shebang:

1
#!/usr/bin/env python2.7

When I run the script from its console, it works well.

I have even tried to use the shebang suggested by Harry in its 1st reply but code errors have been raised and decided not to keep going that way. Have you any suggestion on what to check?

Thanks in advance.

Our shebang parser for scheduled tasks is not as good as it could be. Just use:

#!/usr/bin/python2.7

Hello Glenn and many thanks for your reply. I don't understand why but this throws another error message:

Traceback (most recent call last):
  File "/home/giancampo/diff-html/htmlDiff.py", line 22, in <module>
    os.rename("new_html.html", "old_html.html")
OSError: [Errno 2] No such file or directory

2017-11-23 17:26:06 -- Completed task, took 2.00 seconds, return code was 1.

Again, this works perfectly running the script from its console.

Your code is making assumptions about what the working directory is. See http://help.pythonanywhere.com/pages/NoSuchFileOrDirectory/

Hello Glenn, using the absolute paths, instead of the relative ones, fixed it!

Many thanks for your support.

:)