简体   繁体   中英

firebase and python: ModuleNotFoundError: No module named 'urllib3'

I've been trying to create a simple authentication db using firebase and connecting it to a new python project which will act as a server later on. the problem is I just can't connect the firebase with pycharm

import pyrebase
firebaseConfig = {`the config dictionary I got from firebase (ofc I made all the keys to be of type string)}
firebase = pyrebase.initialize_app(firebaseConfig)
authent = firebase.auth()

but I always get the same error: ModuleNotFoundError: No module named 'urllib3' I have tried to import the urllib3 package but I get a different error AttributeError: module 'collections' has no attribute 'MutableMapping'

edit: the tracebacks:

Traceback (most recent call last):
  File "C:\Users\eliad\pythonProject\lib\site-packages\requests\packages\__init__.py", line 27, in <module>
    from . import urllib3
  File "C:\Users\eliad\pythonProject\lib\site-packages\requests\packages\urllib3\__init__.py", line 8, in <module>
    from .connectionpool import (
  File "C:\Users\eliad\pythonProject\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 35, in <module>
    from .connection import (
  File "C:\Users\eliad\pythonProject\lib\site-packages\requests\packages\urllib3\connection.py", line 54, in <module>
    from ._collections import HTTPHeaderDict
  File "C:\Users\eliad\pythonProject\lib\site-packages\requests\packages\urllib3\_collections.py", line 2, in <module>
    from collections import Mapping, MutableMapping

ImportError: cannot import name 'Mapping' from 'collections' (D:\python\lib\collections\__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\pythonProjects\pythonProject\main.py", line 1, in <module>
 
   import pyrebase
  File "C:\Users\eliad\pythonProject\lib\site-packages\pyrebase\__init__.py", line 1, in <module>
    from .pyrebase import initialize_app
  File "C:\Users\eliad\pythonProject\lib\site-packages\pyrebase\pyrebase.py", line 1, in <module>
    import requests
  File "C:\Users\eliad\pythonProject\lib\site-packages\requests\__init__.py", line 63, in <module>
    from . import utils
  File "C:\Users\eliad\pythonProject\lib\site-packages\requests\utils.py", line 23, in <module>
    from .compat import parse_http_list as _parse_list_header
  File "C:\Users\eliad\pythonProject\lib\site-packages\requests\compat.py", line 11, in <module>
    from .packages import chardet
  File "C:\Users\eliad\pythonProject\lib\site-packages\requests\packages\__init__.py", line 29, in <module>
    import urllib3

ModuleNotFoundError: No module named 'urllib3'

I'm sure the OP has already solved this, but for other people who might still be stuck on this issue:

I solved this by first uninstalling pyrebase completely and then running pip install pyrebase4 .

I think the issue is that if you first install pyrebase by running pip install pyrebase like I did, then you are actually installing this version , which is from March 2017. The latest version of pyrebase is actually Pyrebase 4 , from June 2021. And I didn't have to change the name of the import at all, it just worked.

Hope that helped someone!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM