Author Topic: PYTHON - v2 vs v3 and dependencies...  (Read 599 times)

Dariusz Piatkowski

  • Hero Member
  • *****
  • Posts: 1434
  • Karma: +28/-0
    • View Profile
PYTHON - v2 vs v3 and dependencies...
« on: April 27, 2025, 04:02:26 pm »
So I noticed that libxml2 RPM package got updated to 2.12.4 whereas currently I'm at 2.9.10.

OK, cool, I figured seeing as it was in '-REL' status I'd pull the trigger and get it updated on my machine as well.

However, doing so resulted in an error (during install and not in the pre-check stage ABAICT) and produced the attached error. Basically it turns out my python2-libxml2 has a dependency on the libxml2 RPM.

Hmm...OK, so let me sort this out. Off I went looking thinking that I had already installed Python3 anyways, so why did I still have Python2 on this box, and did it still even make sense to do so.

Take a look at my list of Python stuff that's currently installed here...so yeah, it's a bit of a mix of things.

Now I recall thinking/reading in the past that our RPM/YUM solution required Python2, but checking the RPM/YUM Netlabs page (https://trac.netlabs.org/rpm) I'm not finding anything there calling this out.

So my question is: is Python2 needed for anything RPM/YUM related? I do not use Python for anything but this and maybe one or two little utilities.

It feels like I should perhaps just try to move to Python3...???

Thanks!

Lars

  • Hero Member
  • *****
  • Posts: 1428
  • Karma: +72/-0
    • View Profile
Re: PYTHON - v2 vs v3 and dependencies...
« Reply #1 on: April 27, 2025, 05:03:28 pm »
Make sure that in your \usr\bin directory, you copy python2.7.exe to python.exe (if not already done). Nothing else ever worked for me.
And yes, I also have python 3 installed as I can find python3.9.exe within that same directory. But as I said, using Python3 will only get you into trouble.

Dariusz Piatkowski

  • Hero Member
  • *****
  • Posts: 1434
  • Karma: +28/-0
    • View Profile
Re: PYTHON - v2 vs v3 and dependencies...
« Reply #2 on: April 27, 2025, 05:22:39 pm »
Hey Lars!

Make sure that in your \usr\bin directory, you copy python2.7.exe to python.exe (if not already done). Nothing else ever worked for me.
And yes, I also have python 3 installed as I can find python3.9.exe within that same directory. But as I said, using Python3 will only get you into trouble.

So here are the actually Python RPM packages I have installed:

Code: [Select]
Installed Packages
python-rpm-macros.noarch                      3.9-3.oc00
python-srpm-macros.noarch                     3.9-3.oc00
python-unversioned-command.pentium4           3.9.17-1.oc00
python2-dateutil.noarch                       1:2.8.1-3.oc00
python2-deltarpm.pentium4                     3.6-1.oc00
python2-libxml2.pentium4                      2.9.10-3.oc00
python2-pycurl.pentium4                       7.44.1-3.oc00
python2-rpm.pentium4                          4.13.0-20.oc00
python2-six.noarch                            1.10.0-2.oc00
python2.7.pentium4                            2.7.18-3.oc00
python3.pentium4                              3.9.17-1.oc00
python3-dateutil.noarch                       1:2.8.1-3.oc00
python3-libs.pentium4                         3.9.17-1.oc00
python3-pycurl.pentium4                       7.44.1-3.oc00
python3-six.noarch                            1.10.0-2.oc00

...and that means I have the following in \usr\bin:

Code: [Select]
[G:\usr\bin]dir pyth*

The volume label in drive G is OS2.
The Volume Serial Number is 45B6:75C3.
Directory of G:\usr\bin

 7-04-23  1:50p             9    149 a---  python
 7-04-23  1:50p         1,057    124 a---  python.exe
12-27-21  9:15a            13    153 a---  python2
12-27-21  9:15a            16    156 a---  python2-config
12-27-21  9:15a            15    155 a---  python2.7
12-27-21  9:15a         1,813    124 a---  python2.7-config
12-27-21  9:15a         1,076    124 a---  python2.7.exe
 7-04-23  1:46p            13    153 a---  python3
 7-04-23  1:50p            15    155 a---  python3.9
 7-04-23  1:50p         1,057    124 a---  python3.9.exe

So the weird part is that python.exe is alreday there and it was part of the python-unversioned-command-3.9.17-1.oc00.pentium4 RPM in my case.

Here is what the various python invocationg scripts actually translate to:

Code: [Select]
[G:\usr\bin]type python
./python3
[G:\usr\bin]type python2
python2.7.exe

[G:\usr\bin]type python3
python3.9.exe

Lars

  • Hero Member
  • *****
  • Posts: 1428
  • Karma: +72/-0
    • View Profile
Re: PYTHON - v2 vs v3 and dependencies...
« Reply #3 on: April 27, 2025, 05:34:42 pm »
You have already identified the problem: your python.exe is the same as python3.9.exe.
Just copy python2.7.exe over python.exe and you are fine.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5368
  • Karma: +127/-1
    • View Profile
Re: PYTHON - v2 vs v3 and dependencies...
« Reply #4 on: April 27, 2025, 05:49:48 pm »
You have already identified the problem: your python.exe is the same as python3.9.exe.
Just copy python2.7.exe over python.exe and you are fine.

That's only a good solution if you want to usually use Python2. Other solutions include using the full name, python2.7.exe instead of python2.7 or python2. I think our system doesn't like the multiple dots in the executable name. Another solution is to use sh to launch the python2/python3 script as it seems to get it right.
As for removing python2, it is different enough from python3 it is likely worth keeping it around as there are lots of python2 scripts still out there. I also suspect that there are dependencies between the two in the RPM environment.

Lars

  • Hero Member
  • *****
  • Posts: 1428
  • Karma: +72/-0
    • View Profile
Re: PYTHON - v2 vs v3 and dependencies...
« Reply #5 on: April 27, 2025, 07:36:47 pm »
ANPM comes with Python2 scripts to begin with.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5368
  • Karma: +127/-1
    • View Profile
Re: PYTHON - v2 vs v3 and dependencies...
« Reply #6 on: April 27, 2025, 08:33:57 pm »
ANPM comes with Python2 scripts to begin with.
Are you sure about that? I thought that everything had been updated to python3. Looking, all the scripts simply call python, "#! /usr/bin/python -tt", which here is,
Code: [Select]
W:\usr\bin>python --version
Python 3.9.21


Steven Levine

  • Jr. Member
  • **
  • Posts: 68
  • Karma: +12/-0
    • View Profile
Re: PYTHON - v2 vs v3 and dependencies...
« Reply #7 on: April 27, 2025, 11:10:14 pm »
The hashbang spec would apply if you ran the script from a hashbang aware shell.

ANPM always invokes the scripts via the python command line and forces 2.7 to be used.  The relevant code is at:

  PyExec.VRX:63
      ADDRESS CMD '@python2.7.exe' full_cmd '2>&1 |RXQUEUE' listqueue

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5368
  • Karma: +127/-1
    • View Profile
Re: PYTHON - v2 vs v3 and dependencies...
« Reply #8 on: April 28, 2025, 12:25:28 am »
Ok, thanks