admin管理员组

文章数量:1128974

I think that it is the best to describe my problem with series of prompts. I am missing something, don't know what? How does python3.13 load python 3.11 libs???

Solutions like delete other versions and similar are not good. I want to fix it as it is.

C:\Temp\2025\01\python_ver_check (master) >where python
C:\Program Files\Python313\python.exe
C:\Program Files\Python311\python.exe
C:\OSGeo4W\bin\python.exe
C:\Users\UserName\AppData\Local\Microsoft\WindowsApps\python.exe

C:\Temp\2025\01\python_ver_check (master) >python --version
Python 3.13.1

C:\Temp\2025\01\python_ver_check (master) >type globaj.py
import glob

for g in glob.glob('*'):
    print(g)
C:\Temp\2025\01\python_ver_check (master) >globaj.py
Traceback (most recent call last):
  File "C:\Temp\2025\01\python_ver_check\globaj.py", line 1, in <module>
    import glob
  File "C:\Program Files\Python313\Lib\glob.py", line 5, in <module>
    import re
  File "C:\Program Files\Python313\Lib\re\__init__.py", line 126, in <module>
    from . import _compiler, _parser
  File "C:\Program Files\Python313\Lib\re\_compiler.py", line 18, in <module>
    assert _sre.MAGIC == MAGIC, "SRE module mismatch"
           ^^^^^^^^^^^^^^^^^^^
AssertionError: SRE module mismatch

C:\Temp\2025\01\python_ver_check (master) >python globaj.py
globaj.py
net48
net8

C:\Temp\2025\01\python_ver_check (master) >assoc .py
.py=Python.File

C:\Temp\2025\01\python_ver_check (master) >ftype Python.File
Python.File="C:\WINDOWS\py.exe" "%L" %*

C:\Temp\2025\01\python_ver_check (master) >py --version
Python 3.13.1

C:\Temp\2025\01\python_ver_check (master) >echo %PATH%
C:\Program Files\Python313\Scripts\;C:\Program Files\Python313\;C:\Program Files (x86)\Common Files\Oracle\Java\java8path;...

I think that it is the best to describe my problem with series of prompts. I am missing something, don't know what? How does python3.13 load python 3.11 libs???

Solutions like delete other versions and similar are not good. I want to fix it as it is.

C:\Temp\2025\01\python_ver_check (master) >where python
C:\Program Files\Python313\python.exe
C:\Program Files\Python311\python.exe
C:\OSGeo4W\bin\python.exe
C:\Users\UserName\AppData\Local\Microsoft\WindowsApps\python.exe

C:\Temp\2025\01\python_ver_check (master) >python --version
Python 3.13.1

C:\Temp\2025\01\python_ver_check (master) >type globaj.py
import glob

for g in glob.glob('*'):
    print(g)
C:\Temp\2025\01\python_ver_check (master) >globaj.py
Traceback (most recent call last):
  File "C:\Temp\2025\01\python_ver_check\globaj.py", line 1, in <module>
    import glob
  File "C:\Program Files\Python313\Lib\glob.py", line 5, in <module>
    import re
  File "C:\Program Files\Python313\Lib\re\__init__.py", line 126, in <module>
    from . import _compiler, _parser
  File "C:\Program Files\Python313\Lib\re\_compiler.py", line 18, in <module>
    assert _sre.MAGIC == MAGIC, "SRE module mismatch"
           ^^^^^^^^^^^^^^^^^^^
AssertionError: SRE module mismatch

C:\Temp\2025\01\python_ver_check (master) >python globaj.py
globaj.py
net48
net8

C:\Temp\2025\01\python_ver_check (master) >assoc .py
.py=Python.File

C:\Temp\2025\01\python_ver_check (master) >ftype Python.File
Python.File="C:\WINDOWS\py.exe" "%L" %*

C:\Temp\2025\01\python_ver_check (master) >py --version
Python 3.13.1

C:\Temp\2025\01\python_ver_check (master) >echo %PATH%
C:\Program Files\Python313\Scripts\;C:\Program Files\Python313\;C:\Program Files (x86)\Common Files\Oracle\Java\java8path;...
Share Improve this question asked Jan 8 at 11:45 watbywbarifwatbywbarif 6,9678 gold badges52 silver badges66 bronze badges 2
  • 1 I can give a guess and a recommendation, but no solution. Maybe the lib is only installed for 3.11 not 3.13. Now the recommendation: If you need different versions for different projects, use virtual environments, for example poetry. This way it is ensured that everything is installed in the correct version for your project. Without shared dependencies between your projects – user23307932 Commented Jan 8 at 11:55
  • 1 Good advice for virtual environments, I don't use them and it is useful tool. As for your guess, it is not consistent with 'python globaj.py' working correctly. I have double checked just in case :) – watbywbarif Commented Jan 8 at 12:33
Add a comment  | 

1 Answer 1

Reset to default 0

PYTHONHOME was bad! Never knew this variable is used also, only looked at PATH

echo %PYTHONHOME%
C:\Program Files\Python311

Stil not sure why python globaj.py worked while globay.py alone didn't.

本文标签: