jharris1993
Posts: 32
Joined: Sat Oct 05, 2013 10:26 pm

Raspbian python is 3.7.3 from the IDE but 2.7.16 from a terminal

Thu Oct 17, 2019 6:05 pm

Greetings!

Interesting thing I discovered:

While trying to mess with some python I've written, I noticed that python scripts work wonderfully in the IDE, but fail miserably when run from a terminal window.

Further examination disclosed that the version of python used with the IDE, (Thonny), is 3.7.3, but the version used by the terminal is 2.7.16.

Huh?!! Silly me, I would have thought that both the IDE and the terminal would automagically use the same version, but apparently this is not true.

1. Why is this so?
2. Obviously python 3.7.3 is installed on this latest (?) version of Raspbian, how do I make it global?

Thanks!
Jim "JR"

Some see things as they are, and ask "Why?"
I dream things that never were, and ask "Why Not".

Robert F. Kennedy

“Impossible” is only found in the dictionary of a fool.
Old Chinese Proverb

User avatar
DougieLawson
Posts: 36327
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Raspbian python is 3.7.3 from the IDE but 2.7.16 from a terminal

Thu Oct 17, 2019 6:14 pm

There's two versions of python. Python2 and python3. The default (with an alias of python) is python2. You can't change that or you'll break things.

If you want python3 from a command line use a python3 command.

This mess gets fixed in 2020 when python2.7 goes end-of-life (although it won't be fixed in DebIan/Raspbian until Bullseye emerges as the "stable" version in 2021).

https://pythonclock.org/
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

jharris1993
Posts: 32
Joined: Sat Oct 05, 2013 10:26 pm

Re: Raspbian python is 3.7.3 from the IDE but 2.7.16 from a terminal

Thu Oct 17, 2019 6:32 pm

Sheesh!

I can't imagine why this is so, (version 2 is the current functional version of Python on Debian and the Pi), and it won't get updated until 2021?

* Every book on the subject written anytime in the last few years assumes a 3.n version of Python.
* The current version of Python is 3.8.something. (at least as far as what I read on the Internet is concerned.)
* (IMHO), by the time we get to version 3.something, the current version will be 4!!

No, I'm not the distribution maintainer, (spinning distro's is something else I'd like to learn), but I cannot imagine why we're such laggards.

You have my curiosity riz, as they say. . . .

P.S. I'm waiting for the ISO standard version of Python - right now it's too much of a moving target to program anything serious on - I'd be afraid that every time I sneeze, something would change that would break my code.
Jim "JR"

Some see things as they are, and ask "Why?"
I dream things that never were, and ask "Why Not".

Robert F. Kennedy

“Impossible” is only found in the dictionary of a fool.
Old Chinese Proverb

User avatar
DougieLawson
Posts: 36327
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Raspbian python is 3.7.3 from the IDE but 2.7.16 from a terminal

Thu Oct 17, 2019 6:39 pm

You're right it's a steaming pile of [insert well known emoji here]. It's been a mess since 2012. It's yet another thing that's wrong with python. Ubuntu has fixed it already.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

hippy
Posts: 6104
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Raspbian python is 3.7.3 from the IDE but 2.7.16 from a terminal

Thu Oct 17, 2019 7:53 pm

jharris1993 wrote:
Thu Oct 17, 2019 6:32 pm
(version 2 is the current functional version of Python on Debian and the Pi), and it won't get updated until 2021?

(IMHO), by the time we get to version 3.something, the current version will be 4!!
Python 3.7.3 is already installed by default with Raspbian Buster.

You just have to remember to invoke it using "python3" on the command line because using just "python" invokes python 2 .7.16 and has to be as such so as to not have Raspbian break unexpectedly.
jharris1993 wrote:
Thu Oct 17, 2019 6:32 pm
P.S. I'm waiting for the ISO standard version of Python - right now it's too much of a moving target to program anything serious on - I'd be afraid that every time I sneeze, something would change that would break my code.
Apart from the change from 2 to 3, required because changes did break existing code, Python has generally not broken existing code as new versions have arrived.

Return to “Python”