'Failed to import Cloud Firestore library for Python
I am trying to create a python script to fetch data from my Cloud Firestore database. But I get this weird error:
import firebase_admin
from firebase_admin import credentials, firestore
Exception has occurred: ImportError
Failed to import the Cloud Firestore library for Python. Make sure to install the "google-cloud-firestore" module.
File "C:\Users\Alexandru\Desktop\python\hello.py", line 10, in <module>
from firebase_admin import credentials, firestore
And I think I installed all packages
pip list
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Package Version
------------------------ ----------
astroid 2.4.1
autopep8 1.5.3
CacheControl 0.12.6
cachetools 4.1.0
certifi 2020.4.5.1
cffi 1.14.0
chardet 3.0.4
colorama 0.4.3
cryptography 2.9.2
firebase 3.0.1
firebase-admin 4.3.0
google-api-core 1.18.0
google-api-python-client 1.9.1
google-auth 1.16.1
google-auth-httplib2 0.0.3
google-cloud-core 1.3.0
google-cloud-firestore 1.7.0
google-cloud-storage 1.28.1
google-resumable-media 0.5.1
googleapis-common-protos 1.52.0
grpcio 1.29.0
httplib2 0.18.1
idna 2.9
isort 4.3.21
jwcrypto 0.7
lazy-object-proxy 1.4.3
mccabe 0.6.1
msgpack 1.0.0
pip 20.1.1
protobuf 3.12.2
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycodestyle 2.6.0
pycparser 2.20
pylint 2.5.2
python-firebase 1.2
python-jwt 3.2.6
pytz 2020.1
requests 2.23.0
rsa 4.0
setuptools 41.2.0
six 1.15.0
toml 0.10.1
uritemplate 3.0.1
urllib3 1.25.9
wrapt 1.12.1
Solution 1:[1]
Somehow I issue the following commands and it also worked for me:
$ pip3 install --upgrade pip
$ python3 -m pip install --upgrade setuptools
$ pip3 install --no-cache-dir --force-reinstall -Iv grpcio==1.45
Solution 2:[2]
Reinstall pip, it worked for me :
python -m pip install --upgrade --force-reinstall pip
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Javad Nikbakht |
Solution 2 | Karan Kumar |