ModuleNotFoundError: No module named 'pyasn1' - python

File "D:\Documents\my_project\firebase_login.py", line 1, in <module>
from pyrebase import pyrebase
File "D:\Documents\Python_projects\Test_kivy\venv\lib\site-packages\pyrebase\__init__.py", line 1, in <module>
from .pyrebase import initialize_app
File "D:\Documents\Python_projects\Test_kivy\venv\lib\site-packages\pyrebase\pyrebase.py", line 17, in <module>
from oauth2client.service_account import ServiceAccountCredentials
File "D:\Documents\Python_projects\Test_kivy\venv\lib\site-packages\oauth2client\service_account.py", line 26, in <module>
from oauth2client import crypt
File "D:\Documents\Python_projects\Test_kivy\venv\lib\site-packages\oauth2client\crypt.py", line 23, in <module>
from oauth2client import _pure_python_crypt
File "D:\Documents\Python_projects\Test_kivy\venv\lib\site-packages\oauth2client\_pure_python_crypt.py", line 22, in <module>
from pyasn1.codec.der import decoder
ModuleNotFoundError: No module named 'pyasn1'
Process finished with exit code 1
My code was working like a charm yesterday, today I'm not able to launch it due to pyrebase crashing.
I have this error coming from a PyCharm project.
Pyrebase4: v4.5.0 https://github.com/nhorvath/Pyrebase4

I had the same problem, i solved updating pip.
I also found a similar import issue open on github.

python -m ensurepip
python get-pip.py
pip install awscli --ignore-installed six
ModuleNotFoundError: No module named 'pyasn1_modules'
pip install pyasn1_modules
ModuleNotFoundError: No module named 'google.protobuf'
pip install protobuf

Related

Python modulenotfound error - Is there a "pip" alternative way to install python modules

I am trying to run a program (obviously written in python) and it requires some python modules. One of the missed modules is aiomultiprocess. I tried installing it with pip install aiomultiprocess pip3 install aiomultiprocess python3.7 -m pip install aiomultiprocess but they all come back with the same error message:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 19, in <module>
from setuptools.dist import Distribution
File "/usr/local/lib/python3.7/site-packages/setuptools/dist.py", line 34, in <module>
from setuptools import windows_support
File "/usr/local/lib/python3.7/site-packages/setuptools/windows_support.py", line 2, in <module>
import ctypes
File "/usr/local/lib/python3.7/ctypes/__init__.py", line 10, in <module>
from _ctypes import Union, Structure, Array
File "/usr/local/lib/python3.7/_ctypes.py", line 5, in <module>
import ffi
ModuleNotFoundError: No module named 'ffi'
No ffi module?! Let's get it!
I looked it up and figured it's a foreign library that come, in the case of python, as 2 forms: CFFI & LibFFI, but "ffi" doesn't exist for python. I installed cffi libffi and added them to this path /usr/local/lib/python3.7/site-packages/, but it changed nothing.
So my question is there another way to install python modules without the need of pip??!

ImportError: cannot import name 'app_settings' from 'leaflet'

I was running django project in Anaconda prompt and I got the following error:
File "C:\Users\hp\geoportal_geodjango\mysite\polls\admin.py", line 4, in <module>
from leaflet.admin import LeafletGeoAdmin
File "C:\ProgramData\Anaconda3\lib\site-packages\leaflet\admin.py", line 17, in <module>
from .forms.widgets import LeafletWidget
File "C:\ProgramData\Anaconda3\lib\site-packages\leaflet\forms\widgets.py", line 15, in <module>
from leaflet import app_settings, PLUGINS, PLUGIN_FORMS
ImportError: cannot import name 'app_settings' from 'leaflet' (C:\ProgramData\Anaconda3\lib\site-packages\leaflet\__init__.py)
I tried different leaflet versions.
just use pip install django-leaflet==0.19.0 and it will uninstall the Django-leaflet you installed and install v 0.19.0
Even if you have v0.19 installed, uninstall it and the install it again

I found ModuleNotFoundError: No module named 'tensorflow.contrib'

I try to run python on CMD.
I import tensorflow.contrib in my python file.
import tensorflow.contrib.tensorrt as trt
when running on anaconda with this command.
python run_webcam.py --camera yoga.mp4
it show error:
File "run_webcam.py", line 8, in <module>
from tf_pose.estimator import TfPoseEstimator
File "D:\work\pose estimation\tf-pose-estimation\tf_pose\__init__.py", line 5, in <module>
from tf_pose.runner import infer, Estimator, get_estimator
File "D:\work\pose estimation\tf-pose-estimation\tf_pose\runner.py", line 8, in <module>
from tf_pose import eval
File "D:\work\pose estimation\tf-pose-estimation\tf_pose\eval.py", line 13, in <module>
from tf_pose.estimator import TfPoseEstimator
File "D:\work\pose estimation\tf-pose-estimation\tf_pose\estimator.py", line 14, in <module>
import tensorflow.contrib.tensorrt as trt
ModuleNotFoundError: No module named 'tensorflow.contrib'
I installed
pip install tensorflow
and change the version of tensorflow (Try to uninstall and install many version )
pip uninstall tensorflow
pip install tensorflow==...
but show the same error
Try replacing the following
import tensorflow.contrib.tensorrt as trt (used in ≤ TensorFlow 1.13.1 )
with
from tensorflow.python.compiler.tensorrt import trt(TensorFlow ≥ 1.14.1)
Credit to GitHub

Python ImportError: cannot import name utils

I'm having this issue running a script and it looks like it missed some dependencies, but as you can see below. After installing the missing libraries, it doesn't make any sense.
[ericfoss#maverick-fossum-ddns-net packages]$ python -c "import utils"
[ericfoss#maverick-fossum-ddns-net packages]$ python -c "import requests"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/requests/__init__.py", line 64, in <module>
from . import utils
ImportError: cannot import name utils
[ericfoss#maverick-fossum-ddns-net packages]$
Any idea why utils can be imported, but requests can't?
Check if Requests requirements are satisfied:
$ pip show requests
...
Requires: certifi, idna, chardet, urllib3
I hit the same error but I was missing idna. After installing it the issue resolved.
Well, after pip uninstall requests and reinstalling, it no longer would work at all. Luckily, dnf install python-requests fixed the whole thing...
We may see the unable to import utils error in multiple contexts.
I got this error message when I was migrating scripts from python 2 to 3.
I used the inbuilt python migration automated tool to change the file that is causing the import error using the command 2to3 -w filename
This has resolved the error because the import utils is not back supported by python 3 and we have to convert that code to python 3.
I ran into a similar problem when running Jupyter Lab:
$ jupyter-lab --ip 0.0.0.0
Traceback (most recent call last):
File "/Users/gtholpadi/opt/anaconda3/bin/jupyter-lab", line 6, in <module>
from jupyterlab.labapp import main
File "/Users/gtholpadi/opt/anaconda3/lib/python3.8/site-packages/jupyterlab/labapp.py", line 14, in <module>
from jupyterlab_server import slugify, WORKSPACE_EXTENSION
File "/Users/gtholpadi/opt/anaconda3/lib/python3.8/site-packages/jupyterlab_server/__init__.py", line 4, in <module>
from .app import LabServerApp
File "/Users/gtholpadi/opt/anaconda3/lib/python3.8/site-packages/jupyterlab_server/app.py", line 10, in <module>
from .handlers import add_handlers, LabConfig
File "/Users/gtholpadi/opt/anaconda3/lib/python3.8/site-packages/jupyterlab_server/handlers.py", line 18, in <module>
from .listings_handler import ListingsHandler, fetch_listings
File "/Users/gtholpadi/opt/anaconda3/lib/python3.8/site-packages/jupyterlab_server/listings_handler.py", line 17, in <module>
import requests
File "/Users/gtholpadi/opt/anaconda3/lib/python3.8/site-packages/requests/__init__.py", line 120, in <module>
from . import utils
ImportError: cannot import name 'utils' from partially initialized module 'requests' (most likely due to a circular import) (/Users/gtholpadi/opt/anaconda3/lib/python3.8/site-packages/requests/__init__.py)
requests was already installed when I got this error. I tried pip install -U requests and that solved the problem.
utils package is not installed
You can install package using
sudo pip install utils

Jupyter install for Python 2.7 failed

I have the Anaconda distribution of Python 2.7 and I needed to install the Jupyter notebook package. During the installation process my computer turned off and after that I couldn't continue with the process. I tried to uninstall Jupyter and try installing it again, but I keep getting the same error:
Traceback (most recent call last):
File "C:\Users\Acer\Anaconda\Scripts\ipython-script.py", line 3, in <module>
from IPython import start_ipython
File "C:\Users\Acer\Anaconda\lib\site-packages\IPython\__init__.py", line 49, in <module>
from .terminal.embed import embed
File "C:\Users\Acer\Anaconda\lib\site-packages\IPython\terminal\embed.py", line 19, in <module>
from IPython.terminal.ipapp import load_default_config
File "C:\Users\Acer\Anaconda\lib\site-packages\IPython\terminal\ipapp.py", line 22, in <module>
from IPython.core.completer import IPCompleter
File "C:\Users\Acer\Anaconda\lib\site-packages\IPython\core\completer.py", line 71, in <module>
from IPython.utils import generics
File "C:\Users\Acer\Anaconda\lib\site-packages\IPython\utils\generics.py", line 8, in <module>
from simplegeneric import generic
ImportError: No module named simplegeneric
What should I remove/add in order to make it work?
You need to install the python package simplegeneric. After you install it, you need to install the next package that you fail to import. Continue this process until you dont get any import errors.

Categories