Error import could not be resolved with Python - 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

Related

jupyter contrib nbextension install gives Jupyter command `jupyter-contrib` not found

Trying to (re)install Jupyter's nbextension via the following steps in terminal
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
install --user jupyter nbextension enable varInspector/main
Step 1 = runs and i am able to launch notebooks via "jupyter notebook" in terminal just fine.
Step 2 = fails with
usage: jupyter [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir]
[--paths] [--json] [--debug]
[subcommand]
Jupyter: Interactive Computing
positional arguments:
subcommand the subcommand to launch
optional arguments:
-h, --help show this help message and exit
--version show the versions of core jupyter packages and exit
--config-dir show Jupyter config dir
--data-dir show Jupyter data dir
--runtime-dir show Jupyter runtime dir
--paths show all Jupyter paths. Add --json for machine-readable
format.
--json output paths as machine-readable json
--debug output debug information about paths
Available subcommands: bundlerextension console execute kernel kernelspec
migrate nbconvert nbextension notebook qtconsole run serverextension
troubleshoot trust
Jupyter command `jupyter-contrib` not found.
python version = Python 3.10.2
my list of packages
Package Version
--------------------------------- ---------
argon2-cffi 21.3.0
argon2-cffi-bindings 21.2.0
asteval 0.9.26
asttokens 2.0.5
attrs 21.4.0
backcall 0.2.0
black 22.1.0
bleach 4.1.0
cachetools 5.0.0
certifi 2021.10.8
cffi 1.15.0
charset-normalizer 2.0.12
click 8.0.4
colorama 0.4.4
cycler 0.11.0
db-dtypes 0.3.1
debugpy 1.5.1
decorator 5.1.1
defusedxml 0.7.1
entrypoints 0.4
executing 0.8.2
fonttools 4.29.1
future 0.18.2
google-api-core 2.5.0
google-auth 2.6.0
google-auth-oauthlib 0.5.0
google-cloud-bigquery 2.34.0
google-cloud-bigquery-storage 2.12.0
google-cloud-core 2.2.2
google-crc32c 1.3.0
google-resumable-media 2.3.0
googleapis-common-protos 1.55.0
grpcio 1.44.0
grpcio-status 1.44.0
idna 3.3
ipykernel 6.9.1
ipython 8.0.1
ipython-genutils 0.2.0
ipywidgets 7.6.5
jedi 0.18.1
Jinja2 3.0.3
joblib 1.1.0
jsonschema 4.4.0
jupyter-client 7.1.2
jupyter-console 6.4.0
jupyter-contrib-core 0.3.3
jupyter-contrib-nbextensions 0.5.1
jupyter-core 4.9.2
jupyter-highlight-selected-word 0.2.0
jupyter-latex-envs 1.4.6
jupyter-nbextensions-configurator 0.4.1
jupyterlab-pygments 0.1.2
jupyterlab-widgets 1.0.2
kiwisolver 1.3.2
lmfit 1.0.3
lxml 4.8.0
MarkupSafe 2.1.0
matplotlib 3.5.1
matplotlib-inline 0.1.3
mistune 0.8.4
mpmath 1.2.1
mypy-extensions 0.4.3
nbclient 0.5.11
nbconvert 5.6.1
nbformat 5.1.3
nest-asyncio 1.5.4
notebook 5.7.10
numpy 1.22.2
oauthlib 3.2.0
packaging 21.3
pandas 1.4.1
pandas-gbq 0.17.1
pandocfilters 1.5.0
parso 0.8.3
pathspec 0.9.0
patsy 0.5.2
pickleshare 0.7.5
Pillow 9.0.1
pip 22.0.3
platformdirs 2.5.1
prometheus-client 0.13.1
prompt-toolkit 3.0.28
proto-plus 1.20.3
protobuf 3.19.4
pure-eval 0.2.2
pyarrow 6.0.1
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycparser 2.21
pydata-google-auth 1.3.0
Pygments 2.11.2
pyparsing 3.0.7
pyrsistent 0.18.1
python-dateutil 2.8.2
pytz 2021.3
pywin32 303
pywinpty 2.0.2
PyYAML 6.0
pyzmq 22.3.0
qtconsole 5.2.2
QtPy 2.0.1
requests 2.27.1
requests-oauthlib 1.3.1
rsa 4.8
scikit-learn 1.0.2
scipy 1.8.0
seaborn 0.11.2
Send2Trash 1.8.0
setuptools 58.1.0
six 1.16.0
sklearn 0.0
stack-data 0.2.0
statsmodels 0.13.2
sympy 1.9
terminado 0.13.1
testpath 0.6.0
threadpoolctl 3.1.0
tomli 2.0.1
tornado 6.1
traitlets 5.1.1
uncertainties 3.1.6
urllib3 1.26.8
wcwidth 0.2.5
webencodings 0.5.1
widgetsnbextension 3.5.2
So in case anyone comes across similar for any reason with me encountering this probably due getting a new machine and IT doing their voodoo magic transferring my old stuff to this new machine.
Anyhow, there were a bunch of things I still needed to install after I got my new machine and i am not able to exactly pin point what caused issues from my question but in the end I was able to resolve. Follow me there below ...
Checking out my (doing search) python.exe file I found (search returned) 2 paths where python.exe was present. First one was added as an environment variable (added to windows path)
C:\Users-----\AppData\Local\Programs\Python\Python310
C:\Users----\AppData\Roaming\Python\Python310\
Second one not added. Adding roaming version to path variables did not solve the issue and gave additional errors instead:
Fatal error in launcher: Unable to create process using '"C:\Program Files\Python310\python.exe"
So
I uninstalled python (done that before didnt help doing just that alone)
Deleted all environment variables pointing to python (here is what environment variables are just in case - https://www.computerhope.com/issues/ch000549.htm)
Uninstalled python extension from VS code
(https://marketplace.visualstudio.com/items?itemName=ms-python.python)
Deleted Python folders mentioned in the two paths above
Then reinstalled python (clicked add to path during installation)
Reinstalled VS code python extension
Everything works now.
Best of luck

Ipympl outputs "Error displaying widget: model not found" when running Jupyter Lab in a pipenv

OS: Ubuntu 18.04.6 LTS
Installation:
After running into this issue trying to use pipenv install jupyterlab, I install everything using pip install from within a fresh pipenv shell using Python 3.8.0.
pipenv shell
pip install --upgrade pip
pip install numpy matplotlib jupyterlab ipympl
You can find the Jupyter Lab install doc here.
Running pip list outputs:
Package Version
-------------------- ---------
anyio 3.5.0
argon2-cffi 21.3.0
argon2-cffi-bindings 21.2.0
asttokens 2.0.5
attrs 21.4.0
Babel 2.9.1
backcall 0.2.0
black 21.12b0
bleach 4.1.0
certifi 2021.10.8
cffi 1.15.0
charset-normalizer 2.0.10
click 8.0.3
cycler 0.11.0
debugpy 1.5.1
decorator 5.1.1
defusedxml 0.7.1
entrypoints 0.3
executing 0.8.2
fonttools 4.28.5
idna 3.3
importlib-resources 5.4.0
ipykernel 6.7.0
ipympl 0.8.7
ipython 8.0.1
ipython-genutils 0.2.0
ipywidgets 7.6.5
jedi 0.18.1
Jinja2 3.0.3
json5 0.9.6
jsonschema 4.4.0
jupyter-client 7.1.1
jupyter-core 4.9.1
jupyter-server 1.13.3
jupyterlab 3.2.8
jupyterlab-pygments 0.1.2
jupyterlab-server 2.10.3
jupyterlab-widgets 1.0.2
kiwisolver 1.3.2
MarkupSafe 2.0.1
matplotlib 3.5.1
matplotlib-inline 0.1.3
mistune 0.8.4
mypy-extensions 0.4.3
nbclassic 0.3.5
nbclient 0.5.10
nbconvert 6.4.0
nbformat 5.1.3
nest-asyncio 1.5.4
notebook 6.4.7
numpy 1.22.1
packaging 21.3
pandocfilters 1.5.0
parso 0.8.3
pathspec 0.9.0
pexpect 4.8.0
pickleshare 0.7.5
Pillow 9.0.0
pip 21.3.1
pkg_resources 0.0.0
platformdirs 2.4.1
prometheus-client 0.12.0
prompt-toolkit 3.0.24
ptyprocess 0.7.0
pure-eval 0.2.1
pycparser 2.21
Pygments 2.11.2
pyparsing 3.0.7
pyrsistent 0.18.1
python-dateutil 2.8.2
pytz 2021.3
pyzmq 22.3.0
requests 2.27.1
Send2Trash 1.8.0
setuptools 60.5.0
six 1.16.0
sniffio 1.2.0
stack-data 0.1.4
terminado 0.12.1
testpath 0.5.0
tomli 1.2.3
tornado 6.1
traitlets 5.1.1
typing_extensions 4.0.1
urllib3 1.26.8
wcwidth 0.2.5
webencodings 0.5.1
websocket-client 1.2.3
wheel 0.37.1
widgetsnbextension 3.5.2
zipp 3.7.0
Notably jupyterlab==3.2.8, matplotlib==3.5.1 and ipympl==0.8.7 satisfy the version lookup table
Now running jupyter lab --ip 0.0.0.0 --no-browser from inside the pipenv shell (--ip 0.0.0.0 --no-browser because I'm accessing the notebook on a different machine).
Opening a new notebook with the default Python 3 (ipykernel) kernel, creating two cells
from matplotlib import pyplot as plt
import ipympl # Confirming it is being found by the kernel
%matplotlib widget
# Example found from https://stackoverflow.com/questions/50149562/jupyterlab-interactive-plot
plt.figure()
x = [1,2,3]
y = [4,5,6]
plt.plot(x,y)
plt.show()
Running both cells gives me the common Error message:
Error displaying widget: model not found
What I've already tried:
This question
Where I downgrade:
ipywidgets==7.0.0
ipympl==0.2.1
matplotlib==3.2.0
And install
jupyter labextension install jupyter-matplotlib#0.3.0
No change, same error.
Edit: Using Jupyter Notebook instead of of Jupyter Lab, which means pip install jupyter instead of jupyterlab fixes the issue.
Its what I'll do in lieu of an answer here, but would still like to know if anyone has a straightforward fix for Jupyter Lab.

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

Tensorflow-gpu and Textgenrnn version incompatibility on Windows 10: ModuleNotFoundError: No module named 'tensorflow.contrib'

No matter what I do I cannot seem to get TensorFlow-gpu to work nicely with textgenrnn. The Tensorflow-gpu test is saying everything is running properly Currently, I am getting the error:
ModuleNotFoundError: No module named 'tensorflow.contrib'
when I try to import textgenrnn as
textgen = textgenrnn(name=model_name)
Could someone please provide their working development environment? My pip list is:
Package Version
-------------------- -------------------
absl-py 0.8.1
astor 0.8.0
bleach 1.5.0
cachetools 3.1.1
certifi 2019.9.11
chardet 3.0.4
gast 0.2.2
google-auth 1.6.3
google-auth-oauthlib 0.4.1
google-pasta 0.1.7
grpcio 1.24.3
h5py 2.10.0
html5lib 0.9999999
idna 2.8
joblib 0.14.0
Keras 2.3.1
Keras-Applications 1.0.8
Keras-Preprocessing 1.1.0
Markdown 3.1.1
numpy 1.17.3
oauthlib 3.1.0
opt-einsum 3.1.0
pip 19.3.1
protobuf 3.10.0
pyasn1 0.4.7
pyasn1-modules 0.2.7
PyYAML 5.1.2
requests 2.22.0
requests-oauthlib 1.2.0
rsa 4.0
scikit-learn 0.21.3
scipy 1.3.1
setuptools 41.5.1
six 1.12.0
tb-nightly 2.1.0a20191029
tensorboard 2.0.1
tensorflow-estimator 2.0.1
tensorflow-gpu 2.0.0
termcolor 1.1.0
textgenrnn 1.5.0
tf-estimator-nightly 2.0.0.dev2019102908
tqdm 4.36.1
urllib3 1.25.6
Werkzeug 0.16.0
wheel 0.33.6
wrapt 1.11.2
And my Python Version is 3.6.4, CUDA 10 and cudnn 7.4.1.5. I have tried with lower/higher python versions and CUDA 9 as well.
Thanks.
It seems to be that there is a problem with tensorflow version. As a contrib module, this is no longer available in TensorFlow 2.0
How about you install again your tensorflow-gpu with lower version. I prefer v1.14
pip3 instal tensorflow-gpu==1.14
Speak of the heckin devil, I finally got it after a few days, albeit with console warnings.
Ended up with the above configuration, and uninstalling tensorflow-gpu to install tensorflow-gpu==1.14.0.
I hope this can help someone.

Categories

Resources