-
-
Notifications
You must be signed in to change notification settings - Fork 30.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
regression with latest Python 3.11.1 and _socket not found #100171
Comments
Could you please share the code where you got this error |
Same issue here. I am using python embedded into another application (the PyScripter IDE). It worked fine with 3.11.0 and all previous versions of python. I am using Python on Windows. I have tried adding the DLLs subdirectory to the system path or using os.add_dll_directory with no luck. partial traceback
It works fine from python.exe. importlib.import_module also fails: >>> importlib.import_module("_socket")
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python\Python311\Lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1142, in _find_and_load_unlocked
ModuleNotFoundError: No module named '_socket' |
Ok I found the source of this issue and a workaround: The following works. dllpath = os.path.join(sys.base_prefix, 'DLLs')
sys.path.insert(2, dllpath)
import _socket Now the question is why os.path.join(sys.base_prefix, 'DLLs') is missing... |
3d889dc is probably the culprit.
|
Nice job :) |
I expect this is the same issue as fixed in #100947, since it looks like PyScripter relies on having a separate install of Python. It's not obvious that it's running the executable separately from the original install, but given the timing for the issue appearing I assume it must. |
@zooba Indeed this is the case. Python is embedded in an executable that it is located in a different directory. How can I test whether this resolves the issue? Where is getpath.py located and how is it used by python? |
getpath.py is part of the source code. It gets compiled when we build and merged into the DLL so that we can run it before the compiler is ready to run - no easy way to change it without recompiling Python, I'm afraid. If you set I think a more accurate workaround is to modify your registry - find the 3.11/PythonPath key and add two new keys into it. In the |
I do that for unregistered versions. For registered versions it used to work fine without it before 3.11.1. Will it work as before in 3.11.2? |
It should be fixed for 3.11.2, but I would still recommend setting the variable if you know what it should be set to. The |
I can confirm that calling Py_SetPythonHome before initializing a registered python version works OK with 3.11.1. |
Should be fixed in #100947 |
Hello,
I had an error with latest Python 3.11.1 on windows 10 and Windows 11.
module _socket not found
it concerns socket.py file line 52
I hope, that could be solved easily
Regards
The text was updated successfully, but these errors were encountered: