Forums

Editing in a file - doesn't seem to run

Second 'dumb question' of the day.

I am trying to run the most basic little script https://www.pythonanywhere.com/user/epeesharkey/files/home/epeesharkey/WC2.py

When I press 'Run' I get one of the following :

  • Your console could not be started
  • The console starts but there is an error code about a missing package
  • I get an 'interpreter prompt' with no code run
  • when the console does start it clearly says that it is starting Python3.5 -- the Help documentation says default is 3.6 unless a hashbang in first line.

Documentation also says to use pipx.y to load install a package for version x.y I appreciate have to do this for every different version - but which one is actually the default ? pip3.6 does not work for me, pip3.5 does. Is the default actually Python 3.5 ?

I am not a coding person, just want to be able to do stuff. This is getting very confusing.

Can we take a look at the file in question? We can see your files from our admin interface, but we always ask for explicit permission first.

Hi please be my guest and look. It is the file linked above.

No great urgency though, probably just foi g something stupid. As I say I am not a coder - mostly been using Julytyer Notebooks, but for whatever reason they do not run behind firewall at work (but code in the console seems to be ok)

Hi,

I've managed to get something to work -- I download one of my .ipynb files into .py and that runs (with some minor editing to get rid of the notebook stuff).

Now, this .ipynb is obviously written in Python 2.7, and it starts with

!/usr/bin/env python

That all seems to work fine.

Now, if I try

  1. removing the hashbang : either the console fails to start, or 'launches Python 3.5' and then fails on the first Python 2 command which is not in Python 3 format (a print x)
  2. change the hashbang to #!/usr/bin/env python3.4 : console starts launches Python 3.4 interpreter and again fails on the first Python 2 command.

This is all much more rational, but I am still puzzled by - with no hashbang, why is it not defaulting to Python 3.6 ? and why does sometimes the console not start and sometimes it start with Python 3.5 ?

Looking at this more closely, I think I am being over-eager on pressing run after minor edits. It seems pressing run 'too often' causes the console not to start. Waiting (just 10 secs or so) and hitting run again usually works.

Please feel free to close this issue.

See https://blog.pythonanywhere.com/157/ under the heading "Other nifty stuff, part 2" for why you are defaulting to Python 3.5.

Thanks ...that makes sense now. Bit confusing for a 'non-programmer' user, but I can see why it would happen. The split between Python 2 and Python 3 is quite confusing for a non-coder. why is Python 2 still going 10(?) years after the new version was introduced ? To date myself I can remember the differences between Fortran 4 and Fortran-77 !

You're entirely right, it's taking a long time for everyone to move over to Python 3! The real problem was the number of extra modules that need to be ported; many people aren't just using Python itself, they're using Python with Django (or Flask or...) for websites, or Python with numpy for data analysis, or Python with some other specialised package. And those have taken a while for the maintainers to port across. It looks like the move is almost complete, though -- we'll probably change "python" on its own to mean a version of Python 3 in our next system image.