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

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

Related

How to resolve the hugging face error ImportError: cannot import name 'is_tokenizers_available' from 'transformers.utils'?

I was trying to use the ViTT transfomer. I got the following error with code:
from pathlib import Path
import torchvision
from typing import Callable
root = Path("~/data/").expanduser()
# root = Path(".").expanduser()
train = torchvision.datasets.CIFAR100(root=root, train=True, download=True)
test = torchvision.datasets.CIFAR100(root=root, train=False, download=True)
img2tensor: Callable = torchvision.transforms.ToTensor()
from transformers import ViTFeatureExtractor
feature_extractor = ViTFeatureExtractor.from_pretrained("google/vit-base-patch16-224-in21k")
x, y = train_ds[0]
print(f'{y=}')
print(f'{type(x)=}')
x = img2tensor(x)
x = x.unsqueeze(0) # add batch size 1
out_cls: ImageClassifierOutput = model(x)
print(f'{out_cls.logits=}')
error
Files already downloaded and verified
Files already downloaded and verified
Traceback (most recent call last):
File "/Users/brandomiranda/opt/anaconda3/envs/meta_learning/lib/python3.9/code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 11, in <module>
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/Users/brandomiranda/opt/anaconda3/envs/meta_learning/lib/python3.9/site-packages/transformers/__init__.py", line 30, in <module>
from . import dependency_versions_check
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/Users/brandomiranda/opt/anaconda3/envs/meta_learning/lib/python3.9/site-packages/transformers/dependency_versions_check.py", line 36, in <module>
from .utils import is_tokenizers_available
ImportError: cannot import name 'is_tokenizers_available' from 'transformers.utils' (/Users/brandomiranda/opt/anaconda3/envs/meta_learning/lib/python3.9/site-packages/transformers/utils/__init__.py)
I tried upgrading everything but it still failed. Upgrade commands:
/Users/brandomiranda/opt/anaconda3/envs/meta_learning/bin/python -m
pip install --upgrade pip
pip install --upgrade pip
pip install --upgrade huggingface-hub
pip install --upgrade transformers
pip install --upgrade huggingface-hub
pip install --upgrade datasets
pip install --upgrade tokenizers
pip install pytorch-transformers
pip install --upgrade torch
pip install --upgrade torchvision
pip install --upgrade torchtext
pip install --upgrade torchaudio
# pip install --upgrade torchmeta
pip uninstall torchmeta
Why and how to fix it?
Pip list:
(meta_learning) ❯ pip list
Package Version Editable project location
------------------------------------------------- ---------- ------------------------------------------------------------------------------
absl-py 1.0.0
aiohttp 3.8.1
aiosignal 1.2.0
antlr4-python3-runtime 4.8
argcomplete 2.0.0
async-timeout 4.0.1
attrs 21.4.0
automl-meta-learning 0.1.0 /Users/brandomiranda/automl-meta-learning/automl-proj-src
bcj-cffi 0.5.1
boto 2.49.0
boto3 1.24.85
botocore 1.27.85
Bottleneck 1.3.4
Brotli 1.0.9
brotlicffi 1.0.9.2
brotlipy 0.7.0
cachetools 4.2.4
certifi 2022.9.14
cffi 1.15.1
charset-normalizer 2.0.9
cherry-rl 0.1.4
click 8.0.3
cloudpickle 2.0.0
colorama 0.4.4
configparser 5.2.0
conllu 4.4.1
crcmod 1.7
cryptography 37.0.1
cycler 0.11.0
Cython 0.29.25
dataclasses 0.6
datasets 2.5.1
dill 0.3.4
diversity-for-predictive-success-of-meta-learning 0.0.1 /Users/brandomiranda/diversity-for-predictive-success-of-meta-learning/div_src
docker-pycreds 0.4.0
editdistance 0.6.0
et-xmlfile 1.1.0
fairseq 0.10.0
fastcluster 1.2.4
fasteners 0.17.3
filelock 3.6.0
fonttools 4.28.3
frozenlist 1.2.0
fsspec 2022.7.1
gcs-oauth2-boto-plugin 3.0
gitdb 4.0.9
GitPython 3.1.24
google-apitools 0.5.32
google-auth 2.3.3
google-auth-oauthlib 0.4.6
google-reauth 0.1.1
grpcio 1.42.0
gsutil 5.6
gym 0.21.0
h5py 3.6.0
higher 0.2.1
httplib2 0.20.4
huggingface-hub 0.10.0
hydra-core 1.1.1
idna 3.3
importlib-metadata 4.11.3
jmespath 1.0.1
joblib 1.1.0
kiwisolver 1.3.2
lark-parser 0.12.0
learn2learn 0.1.7
lxml 4.8.0
Markdown 3.3.6
matplotlib 3.5.1
mkl-fft 1.3.1
mkl-random 1.2.2
mkl-service 2.4.0
monotonic 1.6
multidict 5.2.0
multiprocess 0.70.12.2
multivolumefile 0.2.3
munkres 1.1.4
networkx 2.6.3
numexpr 2.8.1
numpy 1.21.5
oauth2client 4.1.3
oauthlib 3.1.1
omegaconf 2.1.1
openpyxl 3.0.10
ordered-set 4.0.2
packaging 21.3
pandas 1.4.2
pathtools 0.1.2
Pillow 9.0.1
pip 22.2.2
plotly 5.4.0
portalocker 2.3.2
progressbar2 3.55.0
promise 2.3
protobuf 3.19.1
psutil 5.8.0
py7zr 0.16.1
pyarrow 9.0.0
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycparser 2.21
pycryptodomex 3.15.0
pyOpenSSL 22.0.0
pyparsing 3.0.6
pyppmd 0.16.1
PySocks 1.7.1
python-dateutil 2.8.2
python-utils 2.5.6
pytorch-transformers 1.2.0
pytz 2021.3
pyu2f 0.1.5
PyYAML 6.0
pyzstd 0.14.4
qpth 0.0.15
regex 2021.11.10
requests 2.28.1
requests-oauthlib 1.3.0
responses 0.18.0
retry-decorator 1.1.1
rsa 4.7.2
s3transfer 0.6.0
sacrebleu 2.0.0
sacremoses 0.0.46
scikit-learn 1.0.1
scipy 1.7.3
seaborn 0.11.2
sentencepiece 0.1.97
sentry-sdk 1.5.1
setproctitle 1.2.2
setuptools 58.0.4
shortuuid 1.0.8
six 1.16.0
sklearn 0.0
smmap 5.0.0
subprocess32 3.5.4
tabulate 0.8.9
tenacity 8.0.1
tensorboard 2.7.0
tensorboard-data-server 0.6.1
tensorboard-plugin-wit 1.8.0
termcolor 1.1.0
texttable 1.6.4
threadpoolctl 3.0.0
tokenizers 0.13.0
torch 1.12.1
torchaudio 0.12.1
torchtext 0.13.1
torchvision 0.13.1
tornado 6.1
tqdm 4.62.3
transformers 4.22.2
typing_extensions 4.3.0
ultimate-anatome 0.1.1 /Users/brandomiranda/ultimate-anatome
ultimate-aws-cv-task2vec 0.0.1 /Users/brandomiranda/ultimate-aws-cv-task2vec
ultimate-utils 0.6.1 /Users/brandomiranda/ultimate-utils/ultimate-utils-proj-src
urllib3 1.26.11
wandb 0.13.3
Werkzeug 2.0.2
wheel 0.37.0
xxhash 2.0.2
yarl 1.8.1
yaspin 2.1.0
zipp 3.8.0
hugging face (HF) related gitissues:
https://github.com/huggingface/transformers/issues/15062
https://github.com/huggingface/tokenizers/issues/120
https://github.com/huggingface/tokenizers/issues/585
https://github.com/huggingface/transformers/issues/11262
SO related: Transformer: Error importing packages. "ImportError: cannot import name 'SAVE_STATE_WARNING' from 'torch.optim.lr_scheduler'"
HF discuss: https://discuss.huggingface.co/t/how-to-resolve-the-hugging-face-error-importerror-cannot-import-name-is-tokenizers-available-from-transformers-utils/23957
reddit: https://www.reddit.com/r/pytorch/comments/xusuuy/how_to_resolve_the_hugging_face_error_importerror/
https://github.com/huggingface/tokenizers/issues/1080
You did not give the model in your question.
Using google colab I could easily run the models openai/clip-vit-base-patch32
from PIL import Image
import requests
from transformers import CLIPProcessor, CLIPModel
model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
inputs = processor(text=["a photo of a cat", "a photo of a dog"],
images=image,
return_tensors="pt",
padding=True)
outputs = model(**inputs)
logits_per_image = outputs.logits_per_image # this is the image-text similarity score
probs = logits_per_image.softmax(dim=1) # we can take the softmax to get the label probabilities
And also google/vit-base-patch16-224-in21k
from transformers import ViTFeatureExtractor, ViTModel
import torch
feature_extractor = ViTFeatureExtractor.from_pretrained("google/vit-base-patch16-224-in21k")
model = ViTModel.from_pretrained("google/vit-base-patch16-224-in21k")
inputs = feature_extractor(image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
last_hidden_states = outputs.last_hidden_state
list(last_hidden_states.shape)
This last example is a good starting point if you want to use this in your own task, as you can pass the last_hidden_state output to a custom model you will train.
However if you try these models directly cifar-100 dataset, you will run into a shape mismatch problem. The models require 244 x 244 images, but cifar dataset is of 32 x 32 images.
If the model was defined, I would argue that it looks like an anaconda problem, I suggest using a different virtual environment to test this, for example, pipenv. Another option would be to use the timm library which also has models for image classification.

ImportError: /usr/lib/aarch64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found

I install the kneed package in linux aarch64 architecture in miniconda3.
When I import kneed inside python,
I got the following error
import kneed
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/su/miniconda3/envs/myenv/lib/python3.10/site-packages/kneed/__init__.py", line 4, in <module>
from .knee_locator import KneeLocator
File "/home/su/miniconda3/envs/myenv/lib/python3.10/site-packages/kneed/knee_locator.py", line 3, in <module>
from scipy.signal import argrelextrema
File "/home/su/miniconda3/envs/myenv/lib/python3.10/site-packages/scipy/signal/__init__.py", line 309, in <module>
from . import _sigtools, windows
File "/home/su/miniconda3/envs/myenv/lib/python3.10/site-packages/scipy/signal/windows/__init__.py", line 41, in <module>
from ._windows import *
File "/home/su/miniconda3/envs/myenv/lib/python3.10/site-packages/scipy/signal/windows/_windows.py", line 7, in <module>
from scipy import linalg, special, fft as sp_fft
File "/home/su/miniconda3/envs/myenv/lib/python3.10/site-packages/scipy/__init__.py", line 211, in __getattr__
return _importlib.import_module(f'scipy.{name}')
File "/home/su/miniconda3/envs/myenv/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/su/miniconda3/envs/myenv/lib/python3.10/site-packages/scipy/fft/__init__.py", line 92, in <module>
from ._helper import next_fast_len
File "/home/su/miniconda3/envs/myenv/lib/python3.10/site-packages/scipy/fft/_helper.py", line 3, in <module>
from ._pocketfft import helper as _helper
File "/home/su/miniconda3/envs/myenv/lib/python3.10/site-packages/scipy/fft/_pocketfft/__init__.py", line 3, in <module>
from .basic import *
File "/home/su/miniconda3/envs/myenv/lib/python3.10/site-packages/scipy/fft/_pocketfft/basic.py", line 6, in <module>
from . import pypocketfft as pfft
ImportError: /usr/lib/aarch64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /home/su/miniconda3/envs/myenv/lib/python3.10/site-packages/scipy/fft/_pocketfft/pypocketfft.cpython-310-aarch64-linux-gnu.so)
When I check libstdc++.so.6,
ls /usr/lib/aarch64-linux-gnu | grep libstdc++.so.6
libstdc++.so.6
libstdc++.so.6.0.28
May I know do I know to install any package to solve the ImportError?
The below are packages that I install
Package Version
---------------------------- ------------
absl-py 1.2.0
appdirs 1.4.4
astunparse 1.6.3
attrs 22.1.0
audioread 2.1.9
cachetools 5.2.0
certifi 2022.6.15
cffi 1.15.1
charset-normalizer 2.1.0
cycler 0.11.0
decorator 5.1.1
distlib 0.3.5
docopt 0.6.2
filelock 3.8.0
flatbuffers 2.0
fonttools 4.34.4
fpdf 1.7.2
gast 0.4.0
google-auth 2.10.0
google-auth-oauthlib 0.4.6
google-pasta 0.2.0
grpcio 1.47.0
h5py 3.7.0
hdfs 2.7.0
idna 3.3
joblib 1.1.0
jsonschema 4.9.1
keras 2.9.0
Keras-Preprocessing 1.1.2
kiwisolver 1.4.4
kneed 0.8.1
libclang 14.0.6
librosa 0.9.2
llvmlite 0.39.0
logger 1.4
Markdown 3.4.1
MarkupSafe 2.1.1
matplotlib 3.5.2
numba 0.56.0
numpy 1.22.0
oauthlib 3.2.0
opt-einsum 3.3.0
packaging 21.3
pandas 1.4.3
Pillow 9.2.0
pip 22.2.2
platformdirs 2.5.2
pooch 1.6.0
protobuf 3.19.4
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycparser 2.21
pyparsing 3.0.9
pyrsistent 0.18.1
python-dateutil 2.8.2
python-Levenshtein 0.12.2
pytz 2022.1
PyYAML 6.0
rdp 0.8
requests 2.28.1
requests-oauthlib 1.3.1
resampy 0.4.0
rsa 4.9
scikit-learn 1.1.2
scipy 1.9.0
seaborn 0.11.2
setuptools 63.4.3
six 1.16.0
SoundFile 0.10.3.post1
tensorboard 2.9.1
tensorboard-data-server 0.6.1
tensorboard-plugin-wit 1.8.1
tensorflow 2.10.0rc0
tensorflow-cpu-aws 2.10.0rc0
tensorflow-estimator 2.9.0
tensorflow-io-gcs-filesystem 0.26.0
termcolor 1.1.0
threadpoolctl 3.1.0
typing_extensions 4.3.0
urllib3 1.26.11
virtualenv 20.16.3
watchdog 2.1.9
Werkzeug 2.2.2
wheel 0.37.1
wrapt 1.14.1
Moreover the packages kears, kneed, librosa, seaborn, sklearn and tensorflow also give the same error. I am not sure where and how to check the dependency of package version. May I know how can I know which versions are compatible with numpy version? Which versions should I install for those packages kears, kneed, librosa, seaborn, sklearn, tensorflow and numpy using pip install in miniconda3.
Install gcc 12.1 via conda like this:
conda install gcc=12.1.0
Ensure that its libraries are in the library search path by setting the appropriate environment variable:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/miniconda3/lib
(using the lib of your specific conda environment may also work: $HOME/miniconda3/env/YOUR_ENV_NAME/lib)
Then start your Python script.
Actually the version `GLIBCXX_3.4.30' exists but not in the folder they are searching in.
What you need to do is to find that folder by:
sudo find / -name "libstdc++.so.6*"
It will show you lots of files in the system, pick the largest one i.e. the one with "libstdc++.so.6.0.30" at the end.
Check if it contains the version you're looking for by:
strings /usr/local/share/miniconda/envs/ffcv/lib/libstdc++.so.6.0.30 | grep GLIBCXX
If it's there, you need to copy it and delete the original one by:
sudo cp /usr/local/share/miniconda/pkgs/libstdcxx-ng-12.2.0-h46fd767_19/lib/libstdc++.so.6.0.30 /usr/lib/x86_64-linux-gnu/
sudo rm /usr/lib/x86_64-linux-gnu/libstdc++.so.6
sudo ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30 /usr/lib/x86_64-linux-gnu/libstdc++.so.6
And there you are! Hope it helps..
This is what worked for me. It was looking in /usr/lib/aarch64-linux-gnu while the correct version was available at $HOME/anaconda3/lib.
You can use the following to ensure that it is available under anaconda3/lib
sudo find / -name "libstdc++.so.6.0.30"
To fix, update the environment variable with correct path
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/anaconda3/lib

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

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 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
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

Categories

Resources