You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ModuleNotFoundError: No module named '_struct' #48
I've installed "Python 3.11.1.80716" and tested a script that works with the previous Python 3.9.10 release.
I get the following error:
Could not find platform dependent libraries <exec_prefix>
Traceback (most recent call last):
File "/Users/xxxxx/ClearMDMCommands/./CoolKids.py", line 2, in <module>
import requests
File "/Library/ManagedFrameworks/Python/Python3.framework/Versions/3.11/lib/python3.11/site-packages/requests/__init__.py", line 43, in <module>
import urllib3
File "/Library/ManagedFrameworks/Python/Python3.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/__init__.py", line 11, in <module>
from . import exceptions
File "/Library/ManagedFrameworks/Python/Python3.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/exceptions.py", line 3, in <module>
from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead
File "/Library/ManagedFrameworks/Python/Python3.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/packages/six.py", line 693, in <module>
import struct
File "/Library/ManagedFrameworks/Python/Python3.framework/Versions/3.11/lib/python3.11/struct.py", line 13, in <module>
from _struct import *
ModuleNotFoundError: No module named '_struct'
I'll install the other pre-release versions and test with those.
This script could replace the symlink for managed_python3, and solves the immediate issue:
% /usr/local/bin/managed_python3_fixed
Python 3.11.1 (v3.11.1:a7a450f84a, Dec 6 2022, 15:24:06) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> exit()
Hi @erikng
I've tested the releases with a script that uses the requests library.
Both python_recommended_signed-3.9.13.80735 and python_recommended_signed-3.10.11.80735 work as expected.
However both python_recommended_signed-3.11.7.80735 and python_recommended_signed-3.12.1.80735 error with the following errors:
Could not find platform dependent libraries <exec_prefix>
Traceback (most recent call last):
File "/Users/breilly/GitLab/MacOps/devicemigration/./V2_DeviceMigration.py", line 3, in <module>
import requests
File "/Library/ManagedFrameworks/Python/Python3.framework/Versions/3.11/lib/python3.11/site-packages/requests/__init__.py", line 43, in <module>
import urllib3
File "/Library/ManagedFrameworks/Python/Python3.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/__init__.py", line 14, in <module>
from . import exceptions
File "/Library/ManagedFrameworks/Python/Python3.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/exceptions.py", line 3, in <module>
import socket
File "/Library/ManagedFrameworks/Python/Python3.framework/Versions/3.11/lib/python3.11/socket.py", line 51, in <module>
import _socket
ModuleNotFoundError: No module named '_socket'
Could not find platform dependent libraries <exec_prefix>
Traceback (most recent call last):
File "/Users/breilly/GitLab/MacOps/devicemigration/./V2_DeviceMigration.py", line 3, in <module>
import requests
File "/Library/ManagedFrameworks/Python/Python3.framework/Versions/3.12/lib/python3.12/site-packages/requests/__init__.py", line 43, in <module>
import urllib3
File "/Library/ManagedFrameworks/Python/Python3.framework/Versions/3.12/lib/python3.12/site-packages/urllib3/__init__.py", line 14, in <module>
from . import exceptions
File "/Library/ManagedFrameworks/Python/Python3.framework/Versions/3.12/lib/python3.12/site-packages/urllib3/exceptions.py", line 3, in <module>
import socket
File "/Library/ManagedFrameworks/Python/Python3.framework/Versions/3.12/lib/python3.12/socket.py", line 52, in <module>
import _socket
ModuleNotFoundError: No module named '_socket'
Thanks for looking into this.
Ben
I’m #MadeByDyslexia – expect creative thinking & creative spelling.
What is your shebang? Or how are you invoking the script? Per Nick's comment it seemed to suggest that you would not be able to use the direct shebang path by the instead use the shim.
Okay I think my build script failed. I see the original symbolic link and I think it didn't get installed, but you already have it from the 3.9 and 3.10 tests. Will investigate today.
I've tested 3.12.1.80737 and I am able to import the requests library
→ managed_python3
Python 3.12.1 (v3.12.1:2305ca5144, Dec 7 2023, 17:23:39) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> exit()
so interestingly, I can't get the error reported with requests when not using the shim
→ /Library/ManagedFrameworks/Python/Python3.framework/Versions/3.12/bin/python3.12
Python 3.12.1 (v3.12.1:2305ca5144, Dec 7 2023, 17:23:39) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>>
I read the other linked ticket again and now I understand why. so if you call it's full path it works, the shim is what doesn't work. I'm closing this as it's solved for now with the hack nick posted.
Activity
notverypc commentedon Jan 10, 2023
Just tested the same script with:
python_recommended_signed-3.10.9.80716.pkg
python_recommended_signed-3.9.13.80712.pkg
And the script works with both of those versions.
natewalck commentedon Jan 10, 2023
Thanks for doing this testing. It looks like requests itself doesn't full support Python 3.11.x yet: https://github.com/psf/requests/releases/tag/v2.28.0
In the meantime, perhaps we should mark 3.11 as
betaor otherwise indicate that not all libraries may support it.notverypc commentedon Jan 11, 2023
I think labelling it
betawould be good.MagerValp commentedon Feb 24, 2023
I don't think this has anything to do with requests per se, it's a general issue with 3.11 and relocatable-python:
gregneagle/relocatable-python#31
nmcspadden commentedon Jun 20, 2023
With gregneagle/relocatable-python#31 (comment), I was able to work around this with simple script:
This script could replace the symlink for
managed_python3, and solves the immediate issue:erikng commentedon Feb 2, 2024
Per the suggestion by Nick I have potentially applied his fix for both 3.11 and 3.12
https://github.com/macadmins/python/releases/tag/v3.11.7.80735
https://github.com/macadmins/python/releases/tag/v3.12.1.80735
need help testing.
notverypc commentedon Feb 2, 2024
Hi @erikng
I've tested the releases with a script that uses the
requestslibrary.Both
python_recommended_signed-3.9.13.80735andpython_recommended_signed-3.10.11.80735work as expected.However both
python_recommended_signed-3.11.7.80735andpython_recommended_signed-3.12.1.80735error with the following errors:Thanks for looking into this.
Ben
I’m #MadeByDyslexia – expect creative thinking & creative spelling.
erikng commentedon Feb 2, 2024
What is your shebang? Or how are you invoking the script? Per Nick's comment it seemed to suggest that you would not be able to use the direct shebang path by the instead use the shim.
erikng commentedon Feb 2, 2024
Okay I think my build script failed. I see the original symbolic link and I think it didn't get installed, but you already have it from the 3.9 and 3.10 tests. Will investigate today.
erikng commentedon Feb 2, 2024
https://github.com/macadmins/python/releases/tag/v3.9.13.80737
https://github.com/macadmins/python/releases/tag/v3.10.11.80737
https://github.com/macadmins/python/releases/tag/v3.11.7.80737
https://github.com/macadmins/python/releases/tag/v3.12.1.80737
I've tested 3.12.1.80737 and I am able to import the requests library
erikng commentedon Feb 2, 2024
so interestingly, I can't get the error reported with requests when not using the shim
erikng commentedon Feb 2, 2024
I read the other linked ticket again and now I understand why. so if you call it's full path it works, the shim is what doesn't work. I'm closing this as it's solved for now with the hack nick posted.