Answer the question
In order to leave comments, you need to log in
Why is runserver not working through django-admin even though it works through manage.py?
Project structure:
mysite/
- config/
- settings/ [common.py, dev.py, prod.py]
- urls.py
- wsgi.py
- __init__.py
- manage.py
Traceback (most recent call last):
File "F:\projects\mysite\.venv\lib\site-packages\django\core\management\__init__.py", line 318, in execute
autoreload.check_errors(django.setup)()
File "F:\projects\mysite\.venv\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "F:\projects\mysite\.venv\lib\site-packages\django\__init__.py", line 18, in setup
from django.urls import set_script_prefix
File "F:\projects\mysite\.venv\lib\site-packages\django\urls\__init__.py", line 1, in <module>
from .base import (
File "F:\projects\mysite\.venv\lib\site-packages\django\urls\base.py", line 11, in <module>
from .exceptions import NoReverseMatch, Resolver404
File "F:\projects\mysite\.venv\lib\site-packages\django\urls\exceptions.py", line 3, in <module>
from django.http import Http404
File "F:\projects\mysite\.venv\lib\site-packages\django\http\__init__.py", line 1, in <module>
from django.http.cookie import SimpleCookie, parse_cookie
File "F:\projects\mysite\.venv\lib\site-packages\django\http\cookie.py", line 7, in <module>
from django.utils.six.moves import http_cookies
File "F:\projects\mysite\.venv\lib\site-packages\django\utils\six.py", line 92, in __get__
result = self._resolve()
File "F:\projects\mysite\.venv\lib\site-packages\django\utils\six.py", line 115, in _resolve
return _import_module(self.mod)
File "F:\projects\mysite\.venv\lib\site-packages\django\utils\six.py", line 82, in _import_module
__import__(name)
File "F:\projects\mysite\.venv\lib\site-packages\django\http\__init__.py", line 1, in <module>
from django.http.cookie import SimpleCookie, parse_cookie
ImportError: cannot import name 'SimpleCookie'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "F:\projects\mysite\.venv\lib\site-packages\django\__main__.py", line 9, in <module>
management.execute_from_command_line()
File "F:\projects\mysite\.venv\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line
utility.execute()
File "F:\projects\mysite\.venv\lib\site-packages\django\core\management\__init__.py", line 331, in execute
_parser = self.fetch_command('runserver').create_parser('django', 'runserver')
File "F:\projects\mysite\.venv\lib\site-packages\django\core\management\__init__.py", line 206, in fetch_command
klass = load_command_class(app_name, subcommand)
File "F:\projects\mysite\.venv\lib\site-packages\django\core\management\__init__.py", line 40, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "C:\Python36\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 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 "F:\projects\mysite\.venv\lib\site-packages\django\core\management\commands\runserver.py", line 12, in <module>
from django.core.servers.basehttp import (
File "F:\projects\mysite\.venv\lib\site-packages\django\core\servers\basehttp.py", line 15, in <module>
from wsgiref import simple_server
File "C:\Python36\lib\wsgiref\simple_server.py", line 13, in <module>
from http.server import BaseHTTPRequestHandler, HTTPServer
File "F:\projects\mysite\.venv\lib\site-packages\django\http\__init__.py", line 1, in <module>
from django.http.cookie import SimpleCookie, parse_cookie
File "F:\projects\mysite\.venv\lib\site-packages\django\http\__init__.py", line 1, in <module>
from django.http.cookie import SimpleCookie, parse_cookie
File "F:\projects\mysite\.venv\lib\site-packages\django\http\cookie.py", line 7, in <module>
from django.utils.six.moves import http_cookies
File "F:\projects\mysite\.venv\lib\site-packages\django\utils\six.py", line 92, in __get__
result = self._resolve()
File "F:\projects\mysite\.venv\lib\site-packages\django\utils\six.py", line 115, in _resolve
return _import_module(self.mod)
File "F:\projects\mysite\.venv\lib\site-packages\django\utils\six.py", line 82, in _import_module
__import__(name)
ModuleNotFoundError: No module named 'http.cookies'
Answer the question
In order to leave comments, you need to log in
In general, yes.
Using django-admin.exe and python -m django failed to start runserver.
I think this is a windows specific problem, but still I ran the project without manage.py.
If you look at the docks for versions >=1.8, then django-admin (i.e. binary) is used there. However, older versions used the regular django-admin.py, which is still present in version 1.11. Here's how it works:
path\to\venv\Scripts\activate.bat
python path\to\venv\Scripts\django-admin.py runserver --pythonpath=path\to\project_dir --settings=config.settings.dev
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question