I'm currently doing Harvard Course about Web Programming. I need to convert my html page on website to markdown, so I installed into my conda virtual environment markdown2 and I added it to INSTALLED_APPS in settings.py. But I have a problem when I try to runserver or migrate I am getting an error ModuleNotFoundError. I tried to create another virtual environment but that doesn't work as well.
Thank you for your tips in advance.
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:\Users\petrk\anaconda3\envs\henv\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\petrk\anaconda3\envs\henv\lib\site-packages\django\core\management\__init__.py", line 377, in execute
django.setup()
File "C:\Users\petrk\anaconda3\envs\henv\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\petrk\anaconda3\envs\henv\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Users\petrk\anaconda3\envs\henv\lib\site-packages\django\apps\config.py", line 90, in create
module = import_module(entry)
File "C:\Users\petrk\anaconda3\envs\henv\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'django_markdown2'
INSTALLED_APPS = [
'encyclopedia',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_markdown2',
]
SOLVED
I had to install to my virtual enviroment pip install django-markdown2 instead of just markdown2.
Related
I have a django project that I am trying to connect with a postgres database. However when I try to run the command python manage.py makemigrations I get the following error:
(card_crate_venv) G:\Shared drives\Card Crate\Software Development\card_crate_admin\website>python manage.py makemigrations
Traceback (most recent call last):
File "G:\Shared drives\Card Crate\Software Development\card_crate_admin\website\manage.py", line 22, in <module>
main()
File "G:\Shared drives\Card Crate\Software Development\card_crate_admin\website\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "G:\Shared drives\Card Crate\Software Development\card_crate_admin\card_crate_venv\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "G:\Shared drives\Card Crate\Software Development\card_crate_admin\card_crate_venv\lib\site-packages\django\core\management\__init__.py", line 377, in execute
django.setup()
File "G:\Shared drives\Card Crate\Software Development\card_crate_admin\card_crate_venv\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "G:\Shared drives\Card Crate\Software Development\card_crate_admin\card_crate_venv\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "G:\Shared drives\Card Crate\Software Development\card_crate_admin\card_crate_venv\lib\site-packages\django\apps\config.py", line 90, in create
module = import_module(entry)
File "C:\Users\Ross Waston\AppData\Local\Programs\Python\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 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "G:\Shared drives\Card Crate\Software Development\card_crate_admin\card_crate_venv\lib\site-packages\psycopg2\__init__.py", line 51, in <module>
from psycopg2._psycopg import ( # noqa
ImportError: DLL load failed while importing _psycopg: The specified module could not be found.
settings.py:
INSTALLED_APPS = [
'psycopg2',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'dashboard.apps.DashboardConfig',
]
...
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'development',
'USER': 'superuser',
'PASSWORD': 'admin',
'HOST': '192.168.1.100',
'PORT': '5432',
}
}
packages:
I found that this does not work because I was using python 3.9 as a interpreter. In PyCharm, I created a new interpreter, setting the base interpreter as python 3.7 and reinstalled all my needed packages it worked as expected
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.
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.
I'm using Visual Studio with Python tools to develop my Django project. I've create an app through the IDE. However after adding the app into the INSTALLED_APPS in my settings.py, it is always giving me ModuleNotFound Error
This is the directory structure.
This is how I've added the app
INSTALLED_APPS = [
# Add your apps here to enable them
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'kleis',
]
Stacktrace
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x00000228FCA30A60>
Traceback (most recent call last):
File "C:\Users\Sam\Documents\Exceptions\Projects\Kleis\Backend Django\Server\Server\env\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "C:\Users\Sam\Documents\Exceptions\Projects\Kleis\Backend Django\Server\Server\env\lib\site-packages\django\core\management\commands\runserver.py", line 113, in inner_run
autoreload.raise_last_exception()
File "C:\Users\Sam\Documents\Exceptions\Projects\Kleis\Backend Django\Server\Server\env\lib\site-packages\django\utils\autoreload.py", line 248, in raise_last_exception
raise _exception[1]
File "C:\Users\Sam\Documents\Exceptions\Projects\Kleis\Backend Django\Server\Server\env\lib\site-packages\django\core\management\__init__.py", line 327, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\Sam\Documents\Exceptions\Projects\Kleis\Backend Django\Server\Server\env\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "C:\Users\Sam\Documents\Exceptions\Projects\Kleis\Backend Django\Server\Server\env\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Sam\Documents\Exceptions\Projects\Kleis\Backend Django\Server\Server\env\lib\site-packages\django\apps\registry.py", line 89, in populate
app_config = AppConfig.create(entry)
File "C:\Users\Sam\Documents\Exceptions\Projects\Kleis\Backend Django\Server\Server\env\lib\site-packages\django\apps\config.py", line 90, in create
module = import_module(entry)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\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 'kleis'
I tried with the above solutions but didnt get solved either.
If we miss to import the path in the newly created urls.py we will be seeing this error,
from django.urls import path (refer:https://docs.djangoproject.com/en/2.0/intro/tutorial01/#creating-a-project)
this will solve this error
Good Luck
I have got an error:
ImportError: No module named 'app.settings.ci'; 'app.settings' is not a package.
I want to install CircleCI 2.0 into Django application. The traceback says:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/Users/xxx/anaconda/envs/rf/lib/python3.5/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/Users/xxx/anaconda/envs/rf/lib/python3.5/site-packages/django/core/management/__init__.py", line 317, in execute
settings.INSTALLED_APPS
File "/Users/xxx/anaconda/envs/rf/lib/python3.5/site-packages/django/conf/__init__.py", line 56, in __getattr__
self._setup(name)
File "/Users/xxx/anaconda/envs/rf/lib/python3.5/site-packages/django/conf/__init__.py", line 43, in _setup
self._wrapped = Settings(settings_module)
File "/Users/xxx/anaconda/envs/rf/lib/python3.5/site-packages/django/conf/__init__.py", line 106, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/Users/xxx/anaconda/envs/rf/lib/python3.5/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 953, in _find_and_load_unlocked
ImportError: No module named 'analytics_api.settings.ci'; 'analytics_api.settings' is not a package
I run the command python manage.py makemigrations --settings app.settings.ci when the error happens. I think this command is necessary to install CircleCI 2.0, but is it wrong? How can I fix this? What is wrong with my code?
In settings.py I wrote
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app',
'data',
'user',
]
To have multiple settings files, you need to create a Python module and use it.
/app
|-- settings
| |-- __init__.py
| |-- base.py <--- the current setting.py file
| |-- ci.py
ci.py
from .base import *
# override settings here
Note:
You can set environment variable DJANGO_SETTINGS_MODULE to use the default settings.