pd2
Posts: 27
Joined: Sun Jun 05, 2016 11:42 am

How many versions do I need? !!!

Thu Apr 27, 2017 2:37 pm

I have a new B+ and see that I have the following directories with Python.
python2.7
python3
python3.3
python3.4

What is all this spaghetti? Why would I need 4 versions and how do I clean this up without breaking something.
I only looked because I needed to install pytz and then when I ran a program that needed it pytz could not be found.
Thanks for any info.

User avatar
Paeryn
Posts: 1572
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: How many versions do I need? !!!

Thu Apr 27, 2017 3:33 pm

You actually have 3 versions there, python3 will be a symlink to python3.4 more than likely (or it could be to python3.3).
You have both 2 and 3 because there are plenty of legacy Python2 programs out there that won't work under Python3, there were some major changes between Python2 and Python3.

I don't know why Python3.3 is installed, it isn't on mine. Unless you have an old setup (possibly Wheezy shipped with 3.3?) or you installed something that required it.

As to pytz not being found, which Python did you install it for and which Python are you trying to use it from?
She who travels light — forgot something.

User avatar
scruss
Posts: 1287
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: How many versions do I need? !!!

Thu Apr 27, 2017 4:23 pm

pd2 wrote:Why would I need 4 versions and how do I clean this up without breaking something?
Exec summary: don't worry about it, and leave it alone. It doesn't take up much space and you could break things by meddling.

In their Infinite Wisdom, the Python developers decided to make:
  1. Python 3 slightly but significantly incompatible with Python 2; and
  2. Python 2 officially “expire” in the next few years.
Unfortunately, there's a tonne of code that works just fine in Python 2, and it's going to take work that no-one really wants to do to fix it.

So you need to keep Python 2 and Python 3 around for compatibility. Sometimes older libraries create old-version folders (I have a ‘python2.6’, for some reason) but they're not much to worry about.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

RDS
Posts: 529
Joined: Tue Oct 06, 2015 8:17 am
Location: Lancashire, UK

Re: How many versions do I need? !!!

Thu Apr 27, 2017 10:14 pm

I am yet to understand why Python 3 was not written to be backwards compatible!

User avatar
Paeryn
Posts: 1572
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: How many versions do I need? !!!

Thu Apr 27, 2017 11:12 pm

Because they wanted to improve the language in ways that couldn't be done whilst remaining backwards compatible.
She who travels light — forgot something.

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: How many versions do I need? !!!

Fri Apr 28, 2017 1:34 am

RDS wrote:I am yet to understand why Python 3 was not written to be backwards compatible!
For the same reason they didn't with Perl 6, to drive you insane!

User avatar
TideMan
Posts: 201
Joined: Fri Jun 22, 2012 8:08 am
Location: ChCh, NZ

Re: How many versions do I need? !!!

Fri Apr 28, 2017 4:44 am

Whereas Fortran IV code from the 1960s will work fine with the latest gfortran compiler.

Danilk
Posts: 104
Joined: Wed Feb 01, 2017 7:47 pm
Location: Russia, St-Peterburg

Re: How many versions do I need? !!!

Fri Apr 28, 2017 6:00 am

RDS wrote:I am yet to understand why Python 3 was not written to be backwards compatible!
minor changes print() range() list(range())…

Martin Frezman
Posts: 950
Joined: Mon Oct 31, 2016 10:05 am

Re: How many versions do I need? !!!

Fri Apr 28, 2017 6:26 am

I'm surprised that they don't provide (or somebody doesn't write) a translator (i.e., a program to translate a Python 2 program into a Python 3 program).

I suspect it's not as trivial as one might hope it to be.
If this post appears in the wrong forums category, my apologies.

gkreidl
Posts: 5197
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: How many versions do I need? !!!

Fri Apr 28, 2017 6:54 am

Danilk wrote:
RDS wrote:I am yet to understand why Python 3 was not written to be backwards compatible!
minor changes print() range() list(range())…
No, there's much more involved (which sometimes makes porting from 2 to 3 a real pain): https://docs.python.org/2/howto/pyporting.html
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

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

Re: How many versions do I need? !!!

Fri Apr 28, 2017 7:35 am

It ALL gets fixed in 2 years 11 months 14 days from now
https://pythonclock.org/

Until it doesn't and that python2 retirement date gets moved out again..
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

gkreidl
Posts: 5197
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: How many versions do I need? !!!

Fri Apr 28, 2017 7:48 am

DougieLawson wrote:It ALL gets fixed in 2 years 11 months 14 days from now
https://pythonclock.org/

Until it doesn't and that python2 retirement date gets moved out again..
There are lots of reasons for moving it again: http://lucumr.pocoo.org/2014/1/5/unicode-in-2-and-3/

And on the RPi Python3 is so much slower ...
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

Danilk
Posts: 104
Joined: Wed Feb 01, 2017 7:47 pm
Location: Russia, St-Peterburg

Re: How many versions do I need? !!!

Fri Apr 28, 2017 8:55 am

gkreidl wrote: No, there's much more involved (which sometimes makes porting from 2 to 3 a real pain): https://docs.python.org/2/howto/pyporting.html
life is pain!

User avatar
kusti8
Posts: 3441
Joined: Sat Dec 21, 2013 5:29 pm
Location: USA

Re: How many versions do I need? !!!

Fri Apr 28, 2017 11:16 am

Martin Frezman wrote:I'm surprised that they don't provide (or somebody doesn't write) a translator (i.e., a program to translate a Python 2 program into a Python 3 program).

I suspect it's not as trivial as one might hope it to be.
The already do. It's called 2to3. Or you could also use six.
There are 10 types of people: those who understand binary and those who don't.

Martin Frezman
Posts: 950
Joined: Mon Oct 31, 2016 10:05 am

Re: How many versions do I need? !!!

Fri Apr 28, 2017 11:46 am

The already do. It's called 2to3. Or you could also use six.
OK - good to know.

The next step, then, is, of course, to build that functionality into the Python 3 interpreter, so that it can run either kind of script. Problem solved. On to the next.
If this post appears in the wrong forums category, my apologies.

User avatar
Paeryn
Posts: 1572
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: How many versions do I need? !!!

Fri Apr 28, 2017 11:53 am

Martin Frezman wrote:
The already do. It's called 2to3. Or you could also use six.
OK - good to know.

The next step, then, is, of course, to build that functionality into the Python 3 interpreter, so that it can run either kind of script. Problem solved. On to the next.
No, that won't happen (not unless you want to do it yourself). Python3 intentionally doesn't support the old style. 2to3 isn't a panacea either, AFIAK there are still cases it can't handle.
She who travels light — forgot something.

Martin Frezman
Posts: 950
Joined: Mon Oct 31, 2016 10:05 am

Re: How many versions do I need? !!!

Fri Apr 28, 2017 12:37 pm

No, that won't happen (not unless you want to do it yourself). Python3 intentionally doesn't support the old style. 2to3 isn't a panacea either, AFIAK there are still cases it can't handle.
That was, actually, my point.
If this post appears in the wrong forums category, my apologies.

Danilk
Posts: 104
Joined: Wed Feb 01, 2017 7:47 pm
Location: Russia, St-Peterburg

Re: How many versions do I need? !!!

Fri Apr 28, 2017 2:43 pm

Paeryn wrote:Python3 intentionally doesn't support the old style
hmmm
my Qt4 prog works with 2&3

User avatar
Paeryn
Posts: 1572
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: How many versions do I need? !!!

Fri Apr 28, 2017 3:24 pm

Danilk wrote:
Paeryn wrote:Python3 intentionally doesn't support the old style
hmmm
my Qt4 prog works with 2&3
If you are careful you can write Python code that works under both. Python2 can import from __future__ to get a few Python3 features and you can also wrap code with checks against which version you are running under.
She who travels light — forgot something.

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

Re: How many versions do I need? !!!

Fri Apr 28, 2017 3:44 pm

Martin Frezman wrote:I'm surprised that they don't provide (or somebody doesn't write) a translator (i.e., a program to translate a Python 2 program into a Python 3 program).

I suspect it's not as trivial as one might hope it to be.
It wasn't easy when I looked at doing that, even converting 'print' to 'print()' throws up problems and trying to figure out when '/' should become '//' can be tricky.

It is possible to automatically identify where they may be problems but not so easy to fix them.

Martin Frezman
Posts: 950
Joined: Mon Oct 31, 2016 10:05 am

Re: How many versions do I need? !!!

Fri Apr 28, 2017 3:54 pm

Sounds like a job for TXL!

www.txl.ca

But my point is that assuming it is possible, it should then be the case that the P2 interpreter becomes part of the P3 interpreter. Sort of like how 32 bit Windows runs 16 bit applications (and, similarly, how 64 bit Windows runs 32 bit applications).
If this post appears in the wrong forums category, my apologies.

User avatar
Paeryn
Posts: 1572
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: How many versions do I need? !!!

Fri Apr 28, 2017 4:18 pm

Martin Frezman wrote:Sounds like a job for TXL!

http://www.txl.ca

But my point is that assuming it is possible, it should then be the case that the P2 interpreter becomes part of the P3 interpreter. Sort of like how 32 bit Windows runs 16 bit applications (and, similarly, how 64 bit Windows runs 32 bit applications).
Having them separate makes more sense, a Python2 program will never run Python3 code and vice versa. Then you have all the sub versions...
She who travels light — forgot something.

Danilk
Posts: 104
Joined: Wed Feb 01, 2017 7:47 pm
Location: Russia, St-Peterburg

Re: How many versions do I need? !!!

Fri Apr 28, 2017 6:35 pm

Paeryn wrote: If you are careful you can write Python code that works under both
im totally noob )))

User avatar
kusti8
Posts: 3441
Joined: Sat Dec 21, 2013 5:29 pm
Location: USA

Re: How many versions do I need? !!!

Fri Apr 28, 2017 6:38 pm

The point is that python 2 and 3 is more like C and C++, although with less drastic changes. Python3 was an effort to try and fix all the mistakes that were in Python2 and make it less quirky and more functional. Could they have made it backwards compatible? Sure. But that is a ton more work and also makes that their buggy Python2 version will forever be around. It was a big overhaul. I don't really see what the problem is though. I program in Python3, not Python2 and if there is some library that isn't in 3 I just move on. It also helps that Arch linux has python symlinked to Python3 not Python2 like most systems.
There are 10 types of people: those who understand binary and those who don't.

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

Re: How many versions do I need? !!!

Fri Apr 28, 2017 7:54 pm

kusti8 wrote:Python3 was an effort to try and fix all the mistakes that were in Python2 and make it less quirky and more functional.
Unfortunately it often seems to execute considerably more slowly -

viewtopic.php?f=32&t=172622#p1104397

Return to “Python”

Who is online

Users browsing this forum: No registered users and 16 guests