Failed to import Cloud Firestore library for Python - 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

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

Reinstall pip, it worked for me :
python -m pip install --upgrade --force-reinstall pip

Related

Error import could not be resolved with Python

I'm trying to use Azure-storage-blob with Python importing with
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient
and installed in my .venv with pip install azure-storage-blob and required in requirements.txt with azure-storage-blob
This is my pip list of the environment
Package Version
------------------------- ---------
adal 1.2.7
azure-common 1.1.28
azure-core 1.21.1
azure-cosmos 4.2.0
azure-functions 1.8.0
azure-mgmt-datalake-nspkg 3.0.1
azure-mgmt-nspkg 3.0.2
azure-mgmt-scheduler 2.0.0
azure-mgmt-search 2.1.0
azure-mgmt-servicebus 0.5.3
azure-mgmt-servicefabric 0.2.0
azure-mgmt-signalr 0.1.1
azure-mgmt-subscription 0.2.0
azure-mgmt-trafficmanager 0.50.0
azure-mgmt-web 0.35.0
azure-nspkg 3.0.2
azure-storage-blob 12.9.0
azure-storage-common 2.1.0
backcall 0.2.0
certifi 2021.10.8
cffi 1.15.0
charset-normalizer 2.0.9
click 8.0.4
colorama 0.4.4
cryptography 36.0.1
cycler 0.11.0
debugpy 1.5.1
decorator 5.1.0
entrypoints 0.3
fonttools 4.28.5
idna 3.3
ipykernel 6.6.0
ipython 7.30.1
isodate 0.6.1
itsdangerous 2.1.0
jedi 0.18.1
Jinja2 3.0.3
jupyter-client 7.1.0
jupyter-core 4.9.1
msrest 0.6.21
msrestazure 0.6.4
nest-asyncio 1.5.4
numpy 1.21.5
oauthlib 3.2.0
packaging 21.3
pandas 1.3.5
parso 0.8.3
pickleshare 0.7.5
Pillow 8.4.0
pip 22.0.3
prompt-toolkit 3.0.24
pycparser 2.21
pydocumentdb 2.3.5
Pygments 2.11.0
PyJWT 2.3.0
pymongo 4.0.1
pyparsing 3.0.6
python-dateutil 2.8.2
python-dotenv 0.19.2
pytz 2021.3
pywin32 303
pyzmq 22.3.0
requests 2.26.0
requests-oauthlib 1.3.1
But im getting Import "azure.storage.blob" could not be resolved
How can I solve this problem??
UPDATE: It just don't work in my .venv and under lib/site-package/azure there is not "storage" folder
Try either of the following ways to resolve Import "azure.storage.blob" could not be resolved error:
1. If you are using visual studio code, try following command to install azure-storage-blob:
conda install -c anaconda azure conda install -c conda-forge azure-storage-blob
2. Uninstall older version of azure-storage-blob’ and reinstall: pip uninstall azureandpip uninstall azure-storage`
Reinstall at the specific path:
cdd .venv
pip install azure-storage –upgrade
References: Unresolved import 'azure.storage.blob' when trying to use Python library azure-storage-blob , How to import Azure BlobService in python? and Install Azure Python api on linux: importError: No module named storage.blob
Thanks to everyone I solved recreating .venv

How Do I Check Which PIP packages were installed by me and which came by defualt

I did the pip list command in the command prompt.
This was the output:
Package Version
------------------ ---------
certifi 2021.10.8
charset-normalizer 2.0.7
idna 3.3
pip 21.3.1
pygame 2.1.0
requests 2.26.0
setuptools 57.4.0
urllib3 1.26.7
How do I check which of these I downloaded so I can uninstall them if I wish, and how to check which came by default with python?

import talib --- ModuleNotFoundError: No module named 'talib'

I have an issue with TA-Lib import
I have created a venv for my python project and when I import talib and run my script I get
Traceback (most recent call last):
File "/Users/renaatvandewiele/opt/anaconda3/lib/python3.8/site-packages/flask/cli.py", line 240, in locate_app
__import__(module_name)
File "/Users/renaatvandewiele/Desktop/GIT/bitrade/app.py", line 2, in <module>
import talib
ModuleNotFoundError: No module named 'talib'
I'm on a M1 MacBook Pro I did the brew install ta-lib and in my venv I did pip3 install TA-Lib.
(bitrade) (base) renaatvandewiele#Renaats-MBP bitrade % pip3 list
Package Version
--------------------- -----------
aiohttp 3.8.0
aiosignal 1.2.0
async-timeout 4.0.0
attrs 21.2.0
backports.zoneinfo 0.2.1
certifi 2021.10.8
charset-normalizer 2.0.7
click 8.0.3
dateparser 1.1.0
Flask 2.0.2
frozenlist 1.2.0
idna 3.3
itsdangerous 2.0.1
Jinja2 3.0.2
MarkupSafe 2.0.1
multidict 5.2.0
numpy 1.21.3
pandas 1.3.4
pip 21.3.1
python-binance 1.0.15
python-dateutil 2.8.2
pytz 2021.3
pytz-deprecation-shim 0.1.0.post0
regex 2021.11.2
requests 2.26.0
setuptools 49.2.1
six 1.16.0
TA-Lib 0.4.21
tqdm 4.62.3
typing-extensions 3.10.0.2
tzdata 2021.5
tzlocal 4.1
ujson 4.2.0
urllib3 1.26.7
websockets 9.1
Werkzeug 2.0.2
yarl 1.7.2
anyone who can guide me to a solution please?
Conda base was still open ... Conda deactivate ... no more errors

python module not found after executing shell script even though the module is installed

pip3 list
Package Version
------------------- ------------
apipkg 1.5
apparmor 3.0.3
appdirs 1.4.4
asn1crypto 1.4.0
brotlipy 0.7.0
certifi 2021.5.30
cffi 1.14.6
chardet 4.0.0
cmdln 2.0.0
configobj 5.0.6
createrepo-c 0.17.3
cryptography 3.3.2
cssselect 1.1.0
cupshelpers 1.0
cycler 0.10.0
decorator 5.0.9
idna 3.2
iniconfig 0.0.0
isc 2.0
joblib 1.0.1
kiwisolver 1.3.1
LibAppArmor 3.0.3
lxml 4.6.3
matplotlib 3.4.3
mysqlclient 2.0.3
nftables 0.1
notify2 0.3.1
numpy 1.21.1
opi 2.1.1
ordered-set 3.1.1
packaging 20.9
pandas 1.3.1
Pillow 8.3.1
pip 20.2.4
ply 3.11
psutil 5.8.0
py 1.10.0
pyasn1 0.4.8
pycairo 1.20.1
pycparser 2.20
pycups 2.0.1
pycurl 7.43.0.6
PyGObject 3.40.1
pyOpenSSL 20.0.1
pyparsing 2.4.7
pysmbc 1.0.23
PySocks 1.7.1
python-dateutil 2.8.2
python-linux-procfs 0.6
pytz 2021.1
pyudev 0.22.0
requests 2.25.1
rpm 4.16.1.3
scikit-learn 0.24.2
scipy 1.7.1
setuptools 57.4.0
six 1.16.0
sklearn 0.0
slip 0.6.5
slip.dbus 0.6.5
termcolor 1.1.0
threadpoolctl 2.2.0
torch 1.9.0+cu111
torchaudio 0.9.0
torchvision 0.10.0+cu111
tqdm 4.62.1
typing-extensions 3.10.0.0
urllib3 1.26.6
Above shows my installed modules, but when i go into the project folder, and run the shell script, I get:
Traceback (most recent call last):
File "main.py", line 3, in <module>
import torch
ImportError: No module named torch
Even though in the list above it clearly shows that torch is installed.
Please help. My $PATH is /usr/bin/python:/home/anthony/bin:/usr/local/bin:/usr/bin:/bin:/snap/bin
and my printenv PYTHONPATH is :/usr/bin/python
Let me know if you need any other print outs, I've tried everything, and nothing seems to be working. I am working mainly in pycharm.
It is very likely that pip3 is pointing to a different python instance.
Imagine you had python, python3, python3.6 and python3.8 all installed on your system. Which one would pip3 install packages for? (who knows?)
It is almost always safer to do python3.8 -m pip list/install since you can be sure that python3.8 somefile.py will be using the same files you just saw. (even better, do python3.8 -m venv /path/to/some/virtualenv and then make sure that is activated, then you can be sure pip points to the same python)

Failed to import the Cloud Firestore library for Python - Django Visual Studio

I am trying to use firebase in my python django project. This is on a windows machine using visual studio. I get the error "Failed to import the Cloud Firestore library for Python" when I try to import it:
import firebase_admin
from firebase_admin import firestore
I have tried everything I can find through google including:
Manually installing grpcio
Downgrading protobuff to various versions. This one actually just ends up with a different error depending on which version of protobuff I go with.
Uninstalling and re-installing google-cloud-store and all other dependencies
Re-installing and upgrading pip
And several other minor things over the course of the day that I can't recall. I am at a dead end after a full day of bashing my head against this. Any other solutions or even a direction to look in?
Here is installed packages list:
CacheControl 0.12.6
cachetools 4.1.1
certifi 2020.6.20
cffi 1.14.2
chardet 3.0.4
defusedxml 0.6.0
diff-match-patch 20200713
Django 2.2.16
django-import-export 2.3.0
docutils 0.16
et-xmlfile 1.0.1
firebase-admin 4.3.0
google-api-core 1.22.2
google-api-python-client 1.12.1
google-auth 1.21.1
google-auth-httplib2 0.0.4
google-cloud-core 1.4.1
google-cloud-firestore 1.9.0
google-cloud-storage 1.31.0
google-crc32c 1.0.0
google-resumable-media 1.0.0
googleapis-common-protos 1.52.0
grpcio 1.32.0
httplib2 0.18.1
idna 2.10
jdcal 1.4.1
MarkupPy 1.14
msgpack 1.0.0
mysql-connector-python 8.0.21
odfpy 1.4.1
openpyxl 3.0.5
pip 20.2.3
protobuf 3.13.0
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycparser 2.20
pytz 2020.1
PyYAML 5.3.1
requests 2.24.0
rsa 4.6
setuptools 50.3.0
six 1.15.0
sqlparse 0.3.1
stripe 2.51.0
tablib 2.0.0
uritemplate 3.0.1
urllib3 1.25.10
xlrd 1.2.0
xlwt 1.3.0
Dunno if noteworthy, but when I try to do the imports like this as another post recommended:
import os
import firebase_admin
from google.cloud import firestore
from firebase_admin import firestore
I instead get "DLL load failed: The specified procedure could not be found." in descriptor.py for "rom google.protobuf.pyext import _message". I dunno if its related at all but figured id included the info.
Upgrading to python 3.7.8 fixed this issue for me.

Categories

Resources