Forums

Prevent the Changing of Python Versions When Running Uploaded Scripts

I am new to PythonAnywhere.

For testing purposes, I have upload a basic file, script, written in 2.7. However, when I run it, it seems to run in version 3.4. There are no errors or problems caused by this, but my concern is that perhaps when I later try to run a more involved script, I may have a problem with the system defaulting to 3.4.

Is there a way to prevent scripts from running in any version but what I specify? I want everything to run in 2.7, unless I specify otherwise.

Thank you.

Is this using the "save and run" button in the editor? I can switch that to always use Python 2.7 if you like.

Alternatively you can specify the version of Python on a per-script basis by putting a hashbang (aka shebang) right at the start of the file, like this:

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

Giles

Thanks for the reply, and fast too.

The hashbank add worked fine. No need to make any "always use" change. In the future, I'll mod any uploaded scripts with the hashbang.

Thank you.

Excellent -- glad to help!