Skip to main content

Questions tagged [importerror]

Refers to errors that result from attempting to import a module or library into one's code

importerror
Filter by
Sorted by
Tagged with
2571 votes
41 answers
3.6m views

Importing files from different folder

I have this folder structure: application ├── app │   └── folder │   └── file.py └── app2 └── some_folder └── some_file.py How can I import a function from file.py, from within ...
Ivan's user avatar
  • 30.4k
842 votes
23 answers
664k views

How to fix "Attempted relative import in non-package" even with __init__.py

I'm trying to follow PEP 328, with the following directory structure: pkg/ __init__.py components/ core.py __init__.py tests/ core_test.py __init__.py In core_test.py I have ...
skytreader's user avatar
  • 11.6k
756 votes
16 answers
1.1m views

What can I do about "ImportError: Cannot import name X" or "AttributeError: ... (most likely due to a circular import)"?

I have some code spread across multiple files that try to import from each other, as follows: main.py: from entity import Ent entity.py: from physics import Physics class Ent: ... physics.py: ...
jsells's user avatar
  • 7,569
636 votes
38 answers
2.5m views

Python error "ImportError: No module named"

Python is installed in a local directory. My directory tree looks like this: (local directory)/site-packages/toolkit/interface.py My code is in here: (local directory)/site-packages/toolkit/...
Eduardo's user avatar
  • 20.7k
448 votes
27 answers
1.1m views

ImportError: No module named 'Tkinter' [duplicate]

For some reason, I can't use the Tkinter (or tkinter, on Python 3) module. After running the following command in the python shell: import Tkinter or this, in Python 3: import tkinter I got this ...
RasmusGP's user avatar
  • 5,086
251 votes
41 answers
701k views

Unable to import a module that is definitely installed

After installing mechanize, I don't seem to be able to import it. I have tried installing from pip, easy_install, and via python setup.py install from this repo: https://github.com/abielr/mechanize. ...
roy's user avatar
  • 3,866
216 votes
23 answers
454k views

"ImportError: No module named" when trying to run Python script

I'm trying to run a script that launches, amongst other things, a python script. I get a ImportError: No module named ..., however, if I launch ipython and import the same module in the same way ...
CodeOcelot's user avatar
  • 3,473
184 votes
8 answers
215k views

RequestsDependencyWarning: urllib3 (1.25.2) or chardet (3.0.4) doesn't match a supported version! Fix

Whenever I run my code with requests or do a pip install I get this message /usr/lib/python2.7/site-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.25.2) or chardet (3.0.4) ...
JOhn's user avatar
  • 1,963
165 votes
4 answers
296k views

Attempted relative import with no known parent package [duplicate]

from ..box_utils import decode, nms This line is giving error ImportError: attempted relative import with no known parent package What is this error and how to resolve this error?
Puneet Shekhawat's user avatar
151 votes
9 answers
176k views

ImportError: libSM.so.6: cannot open shared object file: No such file or directory

When trying to import OpenCV, using import cv2 I get the following error: /usr/local/lib/python2.7/dist-packages/cv2/__init__.py in <module>() 7 8 # make IDE's (PyCharm) ...
Dmitry Rastorguev's user avatar
149 votes
16 answers
146k views

ImportError: cannot import name main when running pip --version command in windows7 32 bit

I've installed the latest python (2.7.9) bundled with pip and setuptools for windows 32-bit. I've tried reinstalling pip but the problem persists. Here's the error after running pip --version in ...
Woootiness's user avatar
  • 1,932
147 votes
17 answers
417k views

ImportError: No module named six

I'm trying to build OpenERP project, done with dependencies. It's giving this error now Traceback (most recent call last): File "openerp-client.py", line 105, in <module> File "modules\...
asadullah07's user avatar
  • 1,581
141 votes
19 answers
475k views

ImportError: cannot import name '...' from partially initialized module '...' (most likely due to a circular import)

I'm upgrading an application from Django 1.11.25 (Python 2.6) to Django 3.1.3 (Python 3.8.5) and, when I run manage.py makemigrations, I receive this message: File "/home/eduardo/projdevs/upgrade-...
3WZ's user avatar
  • 1,415
130 votes
15 answers
188k views

ImportError: cannot import name 'soft_unicode' from 'markupsafe'

I am trying to build a docker container with Airflow and Postgres nevertheless getting many errors during build as shown below. I've tried to downgrade markupsafe in my requirements.txt as shown below,...
Arie's user avatar
  • 3,401
126 votes
6 answers
258k views

How can I troubleshoot Python "Could not find platform independent libraries <prefix>"

I'm trying to use Fontcustom to create an icon font using svg files and fontforge. I'm on OSX.7. However, whenever I run the program I get the error Could not find platform independent libraries <...
Lars's user avatar
  • 8,268
117 votes
2 answers
52k views

psycopg2: AttributeError: 'module' object has no attribute 'extras'

In my code I use the DictCursor from psycopg2.extras like this dict_cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor) However, all of the sudden I get the following error when I load the ...
n1000's user avatar
  • 5,254
107 votes
7 answers
142k views

ImportError: No module named mock

So I am trying to use unittest.mock to mock some of my methods in my unit tests. I do: from unittest.mock import MagicMock f = open("data/static/mock_ffprobe_response") subprocess.check_output = ...
Richard Knop's user avatar
  • 82.8k
89 votes
23 answers
243k views

Installing OpenCV for Python on Ubuntu, getting ImportError: No module named cv2.cv

I have an Ubuntu 14.04 system, on which I want to install OpenCV and use it with Python 2.x. I installed OpenCV using the instructions here: https://help.ubuntu.com/community/OpenCV The install ...
robm's user avatar
  • 1,051
81 votes
19 answers
301k views

Why can't Python import Image from PIL?

The single line that I am trying to run is the following: from PIL import Image However simple this may seem, it gives an error: Traceback (most recent call last): File "C:\...\2014-10-22_12-49....
Betohaku's user avatar
  • 925
78 votes
23 answers
123k views

ImportError: Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work

I have seen similar issue but it is not solved either, so I decided to ask. I am trying to visualize my model in keras using from keras.utils import plot_model plot_model(model, to_file='model.png') ...
bit_scientist's user avatar
77 votes
11 answers
91k views

Unable to import sqlite3 using Anaconda Python

I am trying to do the following in Python 3.7.1 on Windows import sqlite3 but I get the following error message Traceback (most recent call last): File "<console>", line 1, in <module>...
G L's user avatar
  • 870
77 votes
9 answers
132k views

What does "Symbol not found / Expected in: flat namespace" actually mean?

When I import a module I built, I get this boost-python related error: Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: dlopen(./myMod.so, 2): Symbol ...
kilojoules's user avatar
  • 9,907
76 votes
2 answers
187k views

How can I import urlparse in Python 3? [duplicate]

I would like to use urlparse, but Python 3 is not finding the module. I do import urlparse, but it gives me this error ImportError: no 'module' named urlparse
Mohamed Mahdi's user avatar
75 votes
12 answers
246k views

ImportError: cannot import name '...' from 'collections' using Python 3.10

I am trying to run my program which uses various dependencies, but since upgrading to Python 3.10 this does not work anymore. When I run "python3" in the terminal and from there import my ...
Mitra's user avatar
  • 761
74 votes
8 answers
153k views

cannot import name 'mydb' from partially initialized module 'connection' in Python

Python 3.8 error ImportError: cannot import name 'mydb' from partially initialized module 'connection' (most likely due to a circular import) (C:\U sers\Mark04\Documents\Python tutorial\databasing\...
Mark Anthony Libres's user avatar
73 votes
4 answers
83k views

Cannot load from mysql.proc. The table is probably corrupted

I know that it looks like duplicate, but the solutions which I found don't work for me. I uninstalled MySQL 5.1 and installed 5.6, and I would like to import a previously exported SQL file back. But ...
Čamo's user avatar
  • 4,035
72 votes
4 answers
96k views

How to get current import paths in Python?

I get an ImportError exception somewhere in the code, but the same module can be imported safely at startup of the application. I'm curious to see which paths Python looks for modules to import, so ...
aligf's user avatar
  • 2,050
64 votes
8 answers
141k views

How to import python file located in same subdirectory in a pycharm project

I have an input error in pycharm when debugging and running. My project structure is rooted properly, etc./HW3/. so that HW3 is the root directory. I have a subfolder in HW3, util, and a file, util/...
Chris's user avatar
  • 30.4k
63 votes
13 answers
88k views

ImportError: No module named Cython.Distutils

I'm having a strange problem while trying to install the Python library zenlib, using its setup.py file. When I run the setup.py file, I get an import error, saying ImportError: No module named ...
Edward Newell's user avatar
59 votes
4 answers
113k views

unexpected reserved word import in node.js

I'm trying to run node.js backend server. I've received error unexpected reserved word on import in Node.js file. The lines in file core.module.js is: 'use strict'; import lodashMixins from './...
Dracontis's user avatar
  • 4,324
58 votes
14 answers
67k views

Django, ImportError: cannot import name Celery, possible circular import?

I went through this example here: http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html All my tasks are in files called tasks.py. After updating celery and adding the file ...
kev's user avatar
  • 9,427
56 votes
16 answers
220k views

Python ImportError: No module named wx

Im sorry to ask this question again. I have searched and found endles repeats of it both on stackoverflow and also on general google search. Unfortunatly I just cant get my system sorted. I have the ...
Luke Bream's user avatar
55 votes
4 answers
28k views

Import statement works on PyCharm but not from terminal

PyCharm 2016.2.3, Mac OS X 10.11.1, Python 3.5 (Homebrew); I have this folder structure project /somepackage /subpackage __init__.py bar.py __init__.py foo.py foo.py: import ...
Pibborn's user avatar
  • 660
52 votes
8 answers
99k views

Can't locate import javax.inject.Inject package

I'm trying to implement Dagger as a dependency injector in an IntelliJ project, but my code is failing on: import javax.inject.Inject; Intellij is finding the 'javax' package, but not the 'inject' ...
Indigo Nai's user avatar
50 votes
9 answers
141k views

python flask import error

I am running the following code from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello World!" if __name__ == "__main__": app.run(host='0.0.0.0', port=80,...
Manarjan Singh Ghai's user avatar
49 votes
8 answers
98k views

ModuleNotFoundError: No module named 'numpy.testing.nosetester'

I was using the Decision Tree and this error was raised. The same situation appeared when I used Back Propagation. How can I solve it? import pandas as pd import numpy as np a = np.test() f = open('E:/...
jiuseki's user avatar
  • 591
47 votes
4 answers
154k views

ImportError: libcblas.so.3: cannot open shared object file: No such file or directory

I am trying to run an Arducam MT9J001 camera on a raspberry pi 3b+. I am getting the following error when I try to run the program, "ImportError: libcblas.so3: cannot open shared object file: No ...
isaiahoptics22's user avatar
47 votes
7 answers
69k views

Setting up a virtualenv: No module named 'pip'

I have a fresh install of Python 3.3.4 on a Windows Server 2008 R2 machine. I've successfully installed the latest versions of Setuptools, Pip and Virtualenv globally: python ez_setup.py easy_install ...
Benjamin Hodgson's user avatar
46 votes
15 answers
132k views

ModuleNotFoundError: No module named 'sklearn.externals.six'

I keep getting the error ModuleNotFoundError: No module named 'sklearn.externals.six' when running the code below: from sklearn.datasets import load_iris from sklearn.model_selection import ...
Fred Cozzi's user avatar
45 votes
12 answers
109k views

ImportError: No module named 'psycopg2._psycopg'

When I try to import psycopg2 it show below log for me: Traceback (most recent call last): File "D:/Desktop/learn/python/webcatch/appserver/testpgsql.py", line 2, in <module> import ...
sappy's user avatar
  • 840
45 votes
1 answer
80k views

python3: ImportError: No module named xxxx [duplicate]

I am new to Python and I am trying to understand a problem, which I see when creating a package. I have the following file structure: (Working-Directory is /my/Python/jmLib2) /my/Python/jmLib2 |...
MatrixClient's user avatar
42 votes
5 answers
102k views

Python package import from parent directory

I've the following source code structure testapp/ ├─ __init__.py ├─ testmsg.py ├─ sub/ │ ├─ __init__.py │ ├─ testprinter.py where testmsg defines the following constant: MSG = "Test message&...
user avatar
41 votes
30 answers
136k views

DLL load failed when importing PyQt5

I have installed PyQt5 on windows platform and and getting an importError: DLL load failed. I have installed pyqt5 using the command pip3 install pyqt5 Successfully installed pyqt5-5.8.1 My ...
gdRow's user avatar
  • 517
41 votes
8 answers
214k views

Python - ModuleNotFoundError: No module named

I'm new in Python and I'm having the following error with this simple example: This is my project structure: python_project . ├── lib │   ├── __init__.py │   └── my_custom_lib.py └── src ├── ...
Nicolas's user avatar
  • 411
40 votes
1 answer
87k views

Catch python 'ImportError' if import from source directory [duplicate]

When one tries to import a module foo while being in the source directory, one gets an rather confusing ImportError message: ImportError: No module named foo. How can I easily catch this case and ...
Julian's user avatar
  • 1,291
38 votes
7 answers
106k views

Import urllib.request, ImportError: No module named request

I am trying to import urllib.request for python 2.7.10 on PyCharm 4.5.4 on Window 10 but getting the error "ImportError: No module named request".
Raj's user avatar
  • 391
37 votes
1 answer
71k views

ImportError: No module named 'flask.ext' [duplicate]

When I import a Flask extension like this, it works fine: from flask_module import Module So the extension is installed correctly. But whenever I try to import a Flask extension like this: from ...
Lewistrick's user avatar
  • 2,789
36 votes
3 answers
145k views

'ImportError: No module named pytz' when trying to import pylab?

As far as I can tell, I don't even need pytz for what I'm doing. I'm re-learning python for image processing using the O'Reilly book 'Programming Computer Vision with Python' for work (and I'm also ...
nale's user avatar
  • 481
36 votes
8 answers
122k views

Error "ImportError: DLL load failed: %1 is not a valid Win32 application"

I have this issue where I try to import cv2 on Python and get the following error message. >>> import cv2 Traceback (most recent call last): File "<stdin>", line 1, in <...
Francis's user avatar
  • 703
35 votes
11 answers
169k views

"no module named PyPDF2" error

I use Spyder, with Python 2.7, on a windows 10. I was able to install the PyPDF2 package with a conda command from my prompt. I said installation complete. Yet, If I try to run a simple import command:...
ALisboa's user avatar
  • 464

1
2 3 4 5
71