Django No module named 'responsive_images' - python

Getting the following error when ported Django from 2.7 to 3.6
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 "C:\Django\CampusStore\venv\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line utility.execute()
File "C:\Django\CampusStore\venv\lib\site-packages\django\core\management\__init__.py", line 377, in execute django.setup()
File "C:\Django\CampusStore\venv\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS)
File "C:\Django\CampusStore\venv\lib\site-packages\django\apps\registry.py", line 91, in populate app_config = AppConfig.create(entry)
File "C:\Django\CampusStore\venv\lib\site-packages\django\apps\config.py", line 90, in create
module = import_module(entry)
File "C:\Program Files (x86)\Python36-32\lib\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
ModuleNotFoundError: No module named 'responsive_images'

You have to make sure you add the library to your INSTALLED_APPS list in settings.py. It's useful to keep in mind the library name as it's downloaded is usually different than it's name in pip. for Example this is installed with pip install django-responsive-images, but responsive_images is what you should include in your INSTALLED_APPS.

Related

Django: ModuleNotFoundError: No module named 'sslserver'

I would like to use https for my Django development server using django-sslserver.
I have installed it using
$ pip install django-sslserver
I have then added it to my settings.py INSTALLED APPS:
INSTALLED_APPS = [
...
'sslserver',
...
]
However, if I now try to start the sslserver like this:
python3 manage.py runssslerver 0.0.0.0:8080
I get the following error:
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/pi/.local/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/home/pi/.local/lib/python3.7/site-packages/django/core/management/__init__.py", line 377, in execute
django.setup()
File "/home/pi/.local/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/pi/.local/lib/python3.7/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/home/pi/.local/lib/python3.7/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
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 'sslserver'
Any idea how to fix this?
If you are using native python in linux, the pip and pip3 is different. You can try pip3 install django-sslserver.
I recommend to use virtual environment in web service development of python, e.g. pipenv.

Django deploy to Heroku No module named 'django_heroku'

I'm tryin to deploy to Heroku and before this error I was getting:
ModuleNotFoundError: No module named 'django-tables2'
Then I installed django-heroku via pip install django-heroku, followed the instructions on how to set it up.
I disabled the collect static for heroku pushed my master branch and everything is fine, but once I do:
heroku run python manage.py migrate
I get the:
ModuleNotFoundError: No module named 'django_heroku'
the complete traceback is this:
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 "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute()
File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/base.py", line 341, in run_from_argv
connections.close_all()
File "/app/.heroku/python/lib/python3.7/site-packages/django/db/utils.py", line 225, in close_all
for alias in self:
File "/app/.heroku/python/lib/python3.7/site-packages/django/db/utils.py", line 219, in __iter__
return iter(self.databases)
File "/app/.heroku/python/lib/python3.7/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/app/.heroku/python/lib/python3.7/site-packages/django/db/utils.py", line 153, in databases
self._databases = settings.DATABASES
File "/app/.heroku/python/lib/python3.7/site-packages/django/conf/__init__.py", line 76, in __getattr__
self._setup(name)
File "/app/.heroku/python/lib/python3.7/site-packages/django/conf/__init__.py", line 63, in _setup
self._wrapped = Settings(settings_module)
File "/app/.heroku/python/lib/python3.7/site-packages/django/conf/__init__.py", line 142, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/app/.heroku/python/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 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 "/app/GPC/settings.py", line 14, in <module>
import django_heroku
ModuleNotFoundError: No module named 'django_heroku'
I have in my settings at the top:
import os
import django_heroku
and in the very bottom:
django_heroku.settings(locals())
in my requirements.txt I have django-heroku
The master branch is updated and I just can find how to fix this.
The problem was that it was not added to the module, it was needed to be added to the virtual env and then do the pip freeze, with that it was solved.

ImportError: cannot import name 'memoize' when doing python3 manage.py migrate

I have an issue with migration in Django using python3 manage.py migrate it shows me about memoize
I have installed django-memoize and included it on my settings.py but it still shows the error.
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/home/mycomputer/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/mycomputer/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/home/mycomputer/.local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/mycomputer/.local/lib/python3.6/site-packages/django/apps/registry.py", line 122, in populate
app_config.ready()
File "/home/mycomputer/.local/lib/python3.6/site-packages/django/contrib/admin/apps.py", line 24, in ready
self.module.autodiscover()
File "/home/mycomputer/.local/lib/python3.6/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/home/mycomputer/.local/lib/python3.6/site-packages/django/utils/module_loading.py", line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/usr/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 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/mycomputer/.local/lib/python3.6/site-packages/adminsortable/admin.py", line 15, in <module>
from django.shortcuts import render
File "/home/mycomputer/.local/lib/python3.6/site-packages/django/shortcuts/__init__.py", line 14, in <module>
from django.core import urlresolvers
File "/home/mycomputer/.local/lib/python3.6/site-packages/django/core/urlresolvers.py", line 19, in <module>
from django.utils.functional import memoize, lazy
ImportError: cannot import name 'memoize'
It should have migrated after installation of memoize.
Thank you for all the support I need to install some dependencies and re-install my python then after that I created a virtual environment and install dependencies.

ModuleNotFoundError: No module named 'widget_tweaks'

I'm writing project using docker and django (2.1).
I've installed module 'django-widget-tweaks' inside a container and added 'widget_tweaks' to INSTALLED_APPS. When I start project using docker-compose up everything works well, but when I want to run something like docker-compose run <container name> python manage.py test in another terminal an error occurs.
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, 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
ModuleNotFoundError: No module named 'widget_tweaks'
But when I directly run the same command python manage.py test inside a docker container, it works. widget-tweaks has been installed both on container and on my machine. Could you advice something to solve the problem?
Thanks in advance!

Can't run django project on mac imported from ubuntu

My colleague started a django project on Ubuntu. I want to run the same project on OS X Yosemite. We both use python3.4 and following packages:
Django (1.8.2)
Pillow (2.8.1)
pip (7.0.3)
setuptools (17.0)
wheel (0.24.0)
And we both run project in virtual env.
When I cloned project, I used
python manage.py syncdb
And I got following results:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/user/Desktop/projectName/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/Users/user/Desktop/projectName/lib/python3.4/site-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File "/Users/user/Desktop/projectName/lib/python3.4/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/user/Desktop/projectName/lib/python3.4/site-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/Users/user/Desktop/projectName/lib/python3.4/site-packages/django/contrib/admin/apps.py", line 22, in ready
self.module.autodiscover()
File "/Users/user/Desktop/projectName/lib/python3.4/site-packages/django/contrib/admin/__init__.py", line 24, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/Users/user/Desktop/projectName/lib/python3.4/site-packages/django/utils/module_loading.py", line 74, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/Users/user/Desktop/projectName/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 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/Users/user/Desktop/projectName/projectName/main/admin.py", line 3, in <module>
from models import ContactLink, ContactPost, Personnel, WorkCategory, Service, Skill, Work, Customer
ImportError: No module named 'models'
I have no idea why this happens and used several methods described in this site and other sites.
What happened and why?
This should have thrown an error on your Ubuntu install as well.
You need to change line 3 of projectName/main/admin.py to:
from .models import ContactLink, ContactPost, Personnel, \
WorkCategory, Service, Skill, Work, Customer
Notice the added dot . in the from .models part. The import should be relative (assuming all of these models exist in the same main app).

Categories

Resources