ModuleNotFoundError: No module named 'import_export'
Asked Answered
B

7

15

I've used the following tutorial. I used the command pip install django-import-export, then added to the Installed Apps section.

    INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'import_export',
    'frontend',
    'userauth',
    'methods',
]

When I run python manage.py collectstatic I get error ModuleNotFoundError: No module named 'import_export'

Brahui answered 6/9, 2017 at 9:59 Comment(1)
If you are using a virtual environments, make sure that you run pip install and manage.py in the same virtual env.Advertising
S
14

Install the import_export module by writing this command in command prompt

pip install --user django-import_export or use pip install django-import_export

Stopover answered 15/5, 2020 at 18:19 Comment(3)
Your package name has an underscore. There should be a hyphen instead.Thomsen
It worked, but I removed the --user, since the requirements.txt should be for every userFundament
Yes in my case the command runs with --user and in your case its runs without --user nice.Stopover
N
3

I guess you used virtual environment to develop some parts of your project (maybe accidentally) and then you switched it off.
Try to reinstall the modules with your virtual environment activated.

Nancinancie answered 6/11, 2019 at 10:25 Comment(0)
M
2

I had the same bug before, and here is what I did.

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.conf',
'import_export',]

Be careful, the order of 'django.conf' and 'import_export' cannot be changed.

Mammet answered 31/10, 2019 at 7:22 Comment(0)
M
1

I guess you have installed Django in virtualenv. Now when you installed django-import-export you forgot to activate your virtual environment. I doubt there is something else.

Also make sure that your virtual environment is enabled when you run django manage.py collectstatic. You might have installed Django outside all virtual environments once in the past (by mistake) and is therefore not raising "Django not found" errors but cannot find import_export because you actually installed it in virtual environment.

Malti answered 6/9, 2017 at 10:7 Comment(3)
I am new to django! Can you please explain me how to activate virtualenvBrahui
Are you using virtual environment?Malti
I've installed virtual environment. But am not using it in my projectBrahui
M
0

Simple please install django-import-export==2.5.0

i hope its work

Multinational answered 14/5, 2021 at 12:47 Comment(0)
L
0

Following worked for me, I still don't understand why.

  1. Delete your virtual env directory.
    rm -rf env

  2. Come out of the virtual env.
    exec $SHELL

  3. Create the virtual environment again.
    python -m venv env

  4. Activate your virtual env.
    source ./env/bin/activate

  5. Install the requirements again.
    pip install -r requirements.txt

And it worked

Logbook answered 24/6, 2021 at 15:14 Comment(0)
H
0

to solve this problem you can try by installing django import-export only, I tried installing import-export which by default is 0.3.1 version and django import-export installs 3.2.0 version and fixed the problem

Heartbreaker answered 13/6, 2023 at 18:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.