ModuleNotFoundError: No module named 'apps.endpointsapps' - python

I am very new to python and linux, I was trying to create an app from a tutorial and this happend when I tried to run a test of my model.
(venv) kali#kali:~/machinelearning/backend/server$ python manage.py test apps.ml.tests
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/home/kali/machinelearning/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/kali/machinelearning/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/home/kali/machinelearning/venv/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/kali/machinelearning/venv/lib/python3.7/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/home/kali/machinelearning/venv/lib/python3.7/site-packages/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'apps.endpointsapps'
This is my first question on stackoverflow too

Please add empty __init__.py file in the apps folder so that it can be recognized by Python as a package.
Check this link out. link
Can you please post the project structure you have? Basically just want to see where that apps exists.

You need to add an empty init.py (4 underscores in total) file in the apps folder for it to be recognized by Python as a package.
Have a look at the documentation for more informations.

Related

Can't create migrations with Django

I'm trying to create migrations for my pet project.
However, I'm experiencing an Error that can't google an answer for:
it says:
`vincent#master-PC:/media/vincent/82944C77944C6FA9/Users/Ghost/Desktop/Python/PB/lesson 40/meeting_planner$ python3 manage.py makemigrations
Traceback (most recent call last):
File "/media/vincent/82944C77944C6FA9/Users/Ghost/Desktop/Python/PB/lesson 40/meeting_planner/manage.py", line 22, in <module>
main()
File "/media/vincent/82944C77944C6FA9/Users/Ghost/Desktop/Python/PB/lesson 40/meeting_planner/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/home/vincent/.local/share/virtualenvs/lesson_40-49hQCJIK/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/home/vincent/.local/share/virtualenvs/lesson_40-49hQCJIK/lib/python3.10/site-packages/django/core/management/__init__.py", line 420, in execute
django.setup()
File "/home/vincent/.local/share/virtualenvs/lesson_40-49hQCJIK/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/vincent/.local/share/virtualenvs/lesson_40-49hQCJIK/lib/python3.10/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/home/vincent/.local/share/virtualenvs/lesson_40-49hQCJIK/lib/python3.10/site-packages/django/apps/config.py", line 193, in create
import_module(entry)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'django.contrib.cont enttypes'
P.S. I'm using SQLite database
I DID define my app in the settings correctly (checked it twice), tried to restart my VScode and restart pipenv too. However, it didn't work.
django.contrib.cont enttypes should be django.contrib.contenttypes

No module named 'imagekit' in django rest framework

i'm running into a very weird error in django rest framework. I tried all the solutions proposed in stackoverflow but nothing.
the error:
Traceback (most recent call last):
File "C:\Users\User\Desktop\IVAN.ru\IVAN_backend\backend\manage.py", line 22, in <module>
main()
File "C:\Users\User\Desktop\IVAN.ru\IVAN_backend\backend\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\User\Desktop\IVAN.ru\IVAN_backend\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "C:\Users\User\Desktop\IVAN.ru\IVAN_backend\lib\site-packages\django\core\management\__init__.py", line 395, in execute
django.setup()
File "C:\Users\User\Desktop\IVAN.ru\IVAN_backend\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\User\Desktop\IVAN.ru\IVAN_backend\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Users\User\Desktop\IVAN.ru\IVAN_backend\lib\site-packages\django\apps\config.py", line 224, in create
import_module(entry)
File "C:\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'imagekit'
please notice that i added 'imagekit' to installed apps , I uninstalled and reinstalled everything.
but nothing worked for me. I installed django-imagekit and uninstalled Imagekit.
i tried to replace 'imagekit' with 'Imagekit' .
Install django-imagekit:
pip install django-imagekit
Use ImageKit in settings.py file:
INSTALLED_APPS = [
"ImageKit"
...
]

Django NameError: name 'model' is not defined

I am altering an existing application so I can expand the use case a bit. I have already created a new model and altered the view and template a bit. Now I want to run migrations, but I keep getting the NameError and a Google search didn't provide me with much more information, especially since I am adding things to a working application rather than creating something from scratch. Is anyone able to help me?
I have added the following line to admin.py:
admin.site.register(InputData)
the error:
C:\var\www\SYSTEM>python manage.py makemigrations
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py", line 357, in execute
django.setup()
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\apps\registry.py", line 120, in populate
app_config.ready()
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\contrib\admin\apps.py", line 24, in ready
self.module.autodiscover()
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\contrib\admin\__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\module_loading.py", line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\var\www\SYSTEM\System\service_development\admin.py", line 201, in <module>
admin.site.register(InputData)
NameError: name 'InputData' is not defined
EDIT:
I have solved it myself. Turns out there was an 'init' file where all models had to be referenced in order to use them in Admin.
This most likely means that you are not importing "InputData" in your admin.py file.
The last two lines of your error give me the idea that you might have forgotten to import 'InputData' class in admin.py file.
File "C:\var\www\SYSTEM\System\service_development\admin.py", line 201, in <module>
admin.site.register(InputData)
NameError: name 'InputData' is not defined
Import 'InputData' class in admin.py and you are good to go :)

Docker app cannot find module named 'graphene_django'

I used the Django Rest Framework cookiecutter available here to scaffold a project. I've made no changes aside from setting up a virtualenv, installing requirements, and running pip install graphene_django. However, when I add graphene_django to the INSTALLED_APPS I receive the following error when attempting to run the server:
ModuleNotFoundError: No module named graphene_django
Any ideas why?
Traceback:
Traceback (most recent call last):
File "manage.py", line 24, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 347, in execute
django.setup()
File "/usr/local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python3.6/site-packages/django/apps/registry.py", line 89, in populate
app_config = AppConfig.create(entry)
File "/usr/local/lib/python3.6/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
Pip freeze:
...
graphene-django==2.0.0
...
Command to run app:
docker-compose up
The issue seems be related to Docker (or more specifically, me being unfamiliar with Docker). Running the docker-compose up --build command solved the issue. Hopefully, that helps someone else!

"ImportError: No module named 'tastypie'" when running "django-admin migrate"

I'm getting the following error stack when trying to issue a "django-admin migrate" command:
Traceback (most recent call last):
File "/usr/bin/django-admin", line 21, in <module>
management.execute_from_command_line()
File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/usr/lib/python3/dist-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/lib/python3/dist-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/usr/lib/python3/dist-packages/django/apps/config.py", line 87, in create
module = import_module(entry)
File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked
ImportError: No module named 'tastypie'
When a run pip list, django-tastypie (0.12.1) is listed.
Anyone knows why django cannot find this module?
Thanks in advance!
Add tastypie to INSTALLED_APPS in your project's settings.py file:
INSTALLED_APPS = (
...
...
'tastypie',
)

Categories