3

I have been trying to fix this error for days and I am running out of ideas.

I am working on a webapp and I tried to install socketIO to try it out. Every since I attempted to install that package, I keep getting the "AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'" message for almost anything I do. I get the error when I try to install a package. I get the error when I try to start the app by running "flask run"

I've tried to start other projects with a different venv but I still get the same error for every single one of those.

"python3 -m ensurepip --upgrade" returns "Requirement already up-to-date" I tried to uninstall setuptools but when I try to reinstall it gives me the same attributeerror aswell. I manually downloaded pip3 and installed it as discribed in this answer https://stackoverflow.com/a/60778810/17014170 I even tried to reinstall my coding program because I thought there might be an error with it. But nothing worked. I can't run any of my programs and I'm starting to get desperate. Does anybody know how to get rid of this error? I don't need to install socketIO or any other package anymore, I just need to be able to use "flask run" again to run my apps.

I am working on Windows 10 with Python 3.7

Edit: I've installed Python 3.9 and created a new venv. My programs work with that. I'd still like to know if there is any way to fix my 3.7 python installation, if anyone has any ideas.

rauser
  • 31
  • 5
  • For a start, search for the error message online (just so you know what it means) and extract a [mcve] from your code. Include the latter and the full error output in your question. As a new user here, take the [tour] and read [ask] as well. – Ulrich Eckhardt Sep 27 '21 at 16:54
  • Same for me -- python broke after installing socketio – warrens Feb 14 '22 at 16:57

2 Answers2

3

I did a bit of research and found socketio is an unmaintained package. Unfortunately, it would attempt to install setuptools==3.3 (while the current version is 62.1.0) ^1. Ever since I installed socketio with pip install socketio, it result in the below error whenever I try to run pip:

AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'

To solve this, I upgraded setuptools with the below command:

python3 -m pip install setuptools --upgrade
0

Similarly my python 3.9.6 broke after pip installing socketio -- or at least it is an odd coincidence!

Anyhow, I "fixed" my python by installing 3.9.7 (I downloaded the Mac OS package and installed it that way, not with an env tool).

Also as well, socketio started to work after doing that.

warrens
  • 1,661
  • 18
  • 16