Django: ModuleNotFoundError: No module named 'sslserver' - python

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.

Related

Django No module named 'responsive_images'

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.

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!

Django No module named 'django.db.migrations.migration'

I had a custom user model in my project. I wanted to delete it and return default user model by deleting all tables in my database and deleting migrations. After this, I tried to run python manage.py makemigrations command but it writes:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/home/irakliy01/Projects/Project/PythonVEnv/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/home/irakliy01/Projects/Project/PythonVEnv/lib/python3.6/site-packages/django/core/management/__init__.py", line 347, in execute
django.setup()
File "/home/irakliy01/Projects/Project/PythonVEnv/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/irakliy01/Projects/Project/PythonVEnv/lib/python3.6/site-packages/django/apps/registry.py", line 89, in populate
app_config = AppConfig.create(entry)
File "/home/irakliy01/Projects/Project/PythonVEnv/lib/python3.6/site-packages/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
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/irakliy01/Projects/Project/PythonVEnv/lib/python3.6/site-packages/django/contrib/contenttypes/apps.py", line 9, in <module>
from .management import (
File "/home/irakliy01/Projects/Project/PythonVEnv/lib/python3.6/site-packages/django/contrib/contenttypes/management/__init__.py", line 2, in <module>
from django.db import DEFAULT_DB_ALIAS, migrations, router, transaction
File "/home/irakliy01/Projects/Project/PythonVEnv/lib/python3.6/site-packages/django/db/migrations/__init__.py", line 1, in <module>
from .migration import Migration, swappable_dependency # NOQA
ModuleNotFoundError: No module named 'django.db.migrations.migration'
I have no idea what I did wrong.
Your Django installation seems corrupted. You can reinstall with:
pip3 uninstall Django
pip3 install Django
Usually this happens if you installed Django in your regular operating system's python installation and then later installed a virtualenv copy and tried to run the django server. You need to reinstall Django in your virtualenv, after removing it first if it already exists.
Assuming you are running in the virtual environment, you might have actually deleted the files under /django/db/migrations/ as well. So the error is obvious here. You would need to reinstall django to get the files back for successful migration.
To do this, check the django version
python -m django --version
Then install the same version using following command
pip install --upgrade --force-reinstall Django==3.2.2

ImportError: No module named 'social_django'

Every time I am running the application from the Github Repository, I am getting the following error:
Traceback (most recent call last):
File "C:/Users/lenovo-pc/Desktop/Django-Social-Authentication-master/socialauth/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python35\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line
utility.execute()
File "C:\Python35\lib\site-packages\django\core\management\__init__.py", line 338, in execute
django.setup()
File "C:\Python35\lib\site-packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Python35\lib\site-packages\django\apps\registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "C:\Python35\lib\site-packages\django\apps\config.py", line 94, in create
module = import_module(entry)
File "C:\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'social_django'
I want to know what is social_django all about? I have installed many libraries, but non of then have satisfied this error:
python-social-auth[django]
social-auth-app-django
But nothing happens. Please let me know what I should do.
The Python executable you use to run the application doesn't have social_django installed. You can verify this by running these commands:
python manage.py shell
import social_django
This will give you an error, for the same reason.
You can install it with:
pip install social-auth-app-django
The github project you are referring to, has dependency on package 'social_django'. You can check it here.
So you would need to install 'social_django' that can be installed by
pip install social-auth-app-django
I know, you have mentioned this in the question itself but I am pretty sure that the package is not installed.

python manage.py: No module named 'admin_tools'

I'm trying to run this command on my django project:
python manage.py makemigrations --empty my_app_name
to create a new empty migration.
When I try to run this command in poweshell, I get this message:
PS C:\Travail\workout\workout-backend\workout_rest> python manage.py makemigrations --empty record
Traceback (most recent call last):
File "manage.py", line 17, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\Ben\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line
utility.execute()
File "C:\Users\Ben\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\management\__init__.py", line 341, in execute
django.setup()
File "C:\Users\Ben\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Ben\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\apps\registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "C:\Users\Ben\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\apps\config.py", line 90, in create
module = import_module(entry)
File "C:\Users\Ben\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'admin_tools'
The error is: ImportError: No module named 'admin_tools'
What am I doing wrong?
I'm on Windows 10 and I'm using VS2017 to developp my Django app.
EDIT:
Something very strange. When I run pip freeze, I get this:
$ pip freeze
astroid==1.4.9
colorama==0.3.7
Django==1.10.3
isort==4.2.5
lazy-object-proxy==1.2.2
mccabe==0.6.1
pylint==1.6.5
six==1.10.0
wrapt==1.10.10
I don't know what are thoses packages. I have no mention of astroid or mccabe in my whole project. Nor in site-package folder, nor in INSTALLED-APP...

Categories

Resources