Python Forum
python and py report different versions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python and py report different versions
#1
I've installed Python 3.7.5 on a Windows 10 machine. No other version of Python was ever installed on that machine that I know of (and no-one else uses it). On the Windows Command Prompt, when I query the version with python -V I get Python 2.4.5, while when I use py -V I get Python 3.7.5.

I'd like to know why because I know that one can tie oneself in knots when packages (e.g. pip) detect the 'wrong' version.

What I have in my system's PATH is %homepath%\AppData\Local\Programs\Python\Python37\, and the same with Scripts\ appended.

Thanks
Reply
#2
try python3 -V on your prompt, i guess it´ll give you Python3.7.5
and you definitely have python 2 version 2.4.5 on that os.
If there isn´t a specific path in PATH, then the python 2 installation is probably somewhere in your windows system directory. Good luck searching for it.
Reply
#3
Thanks ThomasL. Tried python3 -V and got Python 3.8.0! I've started a full search of my registry and found so far that LilyPond (a music notation software I use) has Python 2.4.5 in it's usr\bin\, which is also on my PATH before that of my Python 3.7.5. I assume swapping these would help, but as for the Python 3.8.0... I'll first complete the search of my registry to see what comes up.

Yes, Computer\HKEY_CLASSES_ROOT\Python\shell\open\command has "C:\Program Files (x86)\LilyPond\usr\bin\python.exe" "%1" "%2" "%3" "%4" "%5" "%6" "%7" "%8" "%9", which is Python 2.4.5.
Reply
#4
After a directory and register search, I found that Lilypond and MinGW had installed 'behind my back' Python 2.4.5 and Python 3.8.0, respectively. Since new paths in Windows are appended to the PATH environment variable and I installed Python 3.7.5 last, invoking python.exe resolved to the one in Python 2.4.5 (because I had installed Lilypond before MinGW) and python3.exe to the one in Python 3.8.0 (because there is no python3.exe in Python 2.4.5). As for py.exe, it is in the Windows directory (which has priority over all others) and I assume that (along with pyw.exe) it is replaced by the last Python installed, in this case Python 3.7.5.

The fix has been to move the path of the Python 3.7.5 (which is the one I need at the moment to be the default in my system) higher up in PATH than those of Python 2.4.5 and 3.8.0, and also to ammend the registry keys Computer\HKEY_CLASSES_ROOT\py_auto_file\shell\open\command and Computer\HKEY_CLASSES_ROOT\Python\shell\open\command so that their values point to the python.exe in my Python 3.7.5. (Warning: Tampering with the registry can hang the system.)

Problem solved.

In short: Make sure that the path of the Python you want to be the default in your system is higher up in PATH than that any other, keeping in mind that all sorts of programs install Python for their own use.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to download TLS Report attachment blason16 6 533 Feb-26-2024, 07:36 AM
Last Post: Pedroski55
  Python Launcher (on Windows) only necessary when 2 or more Python versions installed? pstein 1 317 Feb-17-2024, 12:43 PM
Last Post: deanhystad
  Allure Report Generation rotemz 0 781 Jan-24-2023, 08:30 PM
Last Post: rotemz
Question log.exception() without arguments in old Python versions? cthart 5 1,153 Nov-19-2022, 07:09 PM
Last Post: Gribouillis
  Right to left alignment in python report using Reportlab jalal0034 1 1,826 Sep-27-2022, 04:25 AM
Last Post: jalal0034
  Python versions with libexpat fixes raghupcr 5 2,480 Feb-24-2022, 06:26 PM
Last Post: raghupcr
  Installed versions of Python SamHobbs 5 2,506 Sep-02-2021, 02:28 PM
Last Post: jefsummers
  Print Report Invoice nio74maz 0 1,564 Jun-17-2021, 08:25 AM
Last Post: nio74maz
  Different versions of Python3 and Python Led_Zeppelin 2 2,312 Jun-16-2021, 05:31 AM
Last Post: snippsat
  fpdf adding a new font to my report KatMac 0 2,163 Apr-23-2021, 02:19 PM
Last Post: KatMac

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020