Running Ubuntu Server 22.04, and I get this error when I try to run python scripts that I've been using.
The simplest case is literally just:
import requests
This appears to be happening system-wide, even for scripts that use their own virtual environment, which is very weird. Everything was working fine until today, and I haven't messed with pip or python packages recently. Tried looking it up, and nothing of relevance came up. Here is the full output when I try to run a script that is just: import requests
Traceback (most recent call last):
File "/home/mahmoud/http_python_test.py", line 1, in <module>
import requests
File "/home/mahmoud/.local/lib/python3.10/site-packages/requests/__init__.py", line 43, in <module>
import urllib3
File "/home/mahmoud/.local/lib/python3.10/site-packages/urllib3/__init__.py", line 11, in <module>
from . import exceptions
File "/home/mahmoud/.local/lib/python3.10/site-packages/urllib3/exceptions.py", line 3, in <module>
from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead
File "/home/mahmoud/.local/lib/python3.10/site-packages/urllib3/packages/six.py", line 199, in load_module
mod = mod._resolve()
File "/home/mahmoud/.local/lib/python3.10/site-packages/urllib3/packages/six.py", line 113, in _resolve
return _import_module(self.mod)
File "/home/mahmoud/.local/lib/python3.10/site-packages/urllib3/packages/six.py", line 82, in _import_module
__import__(name)
ModuleNotFoundError: No module named 'http.client'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 72, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 21, in <module>
from urllib.request import urlopen
File "/usr/lib/python3.10/urllib/request.py", line 88, in <module>
import http.client
ModuleNotFoundError: No module named 'http.client'
Original exception was:
Traceback (most recent call last):
File "/home/mahmoud/http_python_test.py", line 1, in <module>
import requests
File "/home/mahmoud/.local/lib/python3.10/site-packages/requests/__init__.py", line 43, in <module>
import urllib3
File "/home/mahmoud/.local/lib/python3.10/site-packages/urllib3/__init__.py", line 11, in <module>
from . import exceptions
File "/home/mahmoud/.local/lib/python3.10/site-packages/urllib3/exceptions.py", line 3, in <module>
from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead
File "/home/mahmoud/.local/lib/python3.10/site-packages/urllib3/packages/six.py", line 199, in load_module
mod = mod._resolve()
File "/home/mahmoud/.local/lib/python3.10/site-packages/urllib3/packages/six.py", line 113, in _resolve
return _import_module(self.mod)
File "/home/mahmoud/.local/lib/python3.10/site-packages/urllib3/packages/six.py", line 82, in _import_module
__import__(name)
ModuleNotFoundError: No module named 'http.client'