Description
Bug report
When updating Python 3.11.0 -> 3.11.1 (or reverse to reverse the issue), the ...\Python311\DLLs
folder is suddenly not added anymore to sys.path in embedded startup due to somehow impaired search path algorithm. E.g. in Pythonwin.exe
. And thus things like ctypes, socket, hashlib etc. cannot be imported. But ...\Python311\Lib
and all the other paths are correctly there, just the DLLs path missing.
The same was observed e.g. here:
mhammond/pywin32#1995
The issue is also in current Py 3.12.0a3 at least.
The issue seems not to be with python.exe
startup.
The issue also disappears when I monkey-copy the Pythonwin.exe
next to python.exe
and use that copy.
Note: Pythonwin.exe
locates pythonNN.dll dynamically and does the usual Python init.
And extra confusing: in the registry there is a PythonPath
key like C:\Python312\Lib\;C:\Python312\DLLs\
:
I always thought that the DLLs path is taken from there. But when I edit-damage that like C:\Python312\Lib\;C:\Python312\DLLsx\
e.g., it has no effect :-)
The correct DLLs dir (only) is still in the sys.path in the above working cases, and DLLsx
also does not appear on sys.path in the non-working cases.
Reproduce:
- Win10
- pip install pywin32; run Pythonwin.exe
import ctypes
and/or inspect sys.path after start.
Linked PRs
- gh-100320: Fix path calculations on Windows when python.exe is moved outside of the normal location #100947
- [3.11] gh-100320: Fix path calculations on Windows when python.exe is moved outside of the normal location (GH-100947) #101082
- [3.11] gh-100320: Fix path calculations on Windows when python.exe is moved outside of the normal location (GH-100947) #101080