Can't import module with django-extension RunScript

40 Views Asked by At

Im trying to create backend for my app with django. I have some data that I want to load into my database from scripts I have created. Finally I found django-extensions runscript that can help me do that. But when running

python manage.py runscript import_data_script

I get this error:

(.venv) PS C:\Users\carle\Vscode_desktop\Mat_app\backend_django> python manage.py runscript import_data_script            
Traceback (most recent call last):
  File "C:\Users\carle\Vscode_desktop\Mat_app\backend_django\.venv\Lib\site-packages\django_extensions\management\commands\runscript.py", line 204, in my_import
    t = importlib.import_module(full_module_path)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\carle\AppData\Local\Programs\Python\Python311\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\carle\Vscode_desktop\Mat_app\backend_django\mat\scripts\import_data_script.py", line 2, in <module>
    from exeee import livsmedelsverket_lista
ModuleNotFoundError: No module named 'exeee'
Cannot import module 'mat.scripts.import_data_script': No module named 'exeee'.
No (valid) module for script 'import_data_script' found
Try running with a higher verbosity level like: -v2 or -v3
CommandError: An error has occurred running scripts. See errors above.

I seems like the script "import_data_script" can't find a module it is trying to import named "exeee". This exeee file is also situated within the same directory named "scripts" within my app directory named "mat".

I have followed all the documentation and can't figure out what is wrong.

Any suggestions?

Thanks!

I have tried reading all the documentations, searching for the solution to the error and questions ai, but with no luck.

0

There are 0 best solutions below