Questions tagged [importerror]
Refers to errors that result from attempting to import a module or library into one's code
importerror
3,501
questions
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 ...
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 ...
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:
...
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/...
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 ...
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. ...
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 ...
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) ...
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?
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) ...
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 ...
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\...
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-...
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,...
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 <...
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 ...
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 = ...
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 ...
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....
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')
...
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>...
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 ...
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
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 ...
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\...
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 ...
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 ...
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/...
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 ...
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 './...
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 ...
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 ...
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 ...
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' ...
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,...
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:/...
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 ...
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 ...
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 ...
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 ...
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
|...
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&...
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 ...
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
├── ...
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 ...
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".
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 ...
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 ...
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 <...
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:...