Fish
Fish

Reputation: 225

Django: manage.py works fine but django-admin fails

I've been starting up a new django project (django 1.8.13, python 3.4) and everything is working fine. However, I just noticed, django-admin returns these errors if I use it instead of manage.py

It's reporting there is no module named mysite (name of working project). It's no big deal as the site is fine but I was just wondering why this would happen, it's a brand new install and everything is fine except for this as far as I can tell.

(virtualenv) VirtualBox:# django-admin makemigrations
Traceback (most recent call last):
  File "/usr/share/django-apps/virtualenv/bin/django-admin", line 11, in <module>
    sys.exit(execute_from_command_line())
 File "/usr/share/django-apps/virtualenv/lib/python3.4/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
  File "/usr/share/django-apps/virtualenv/lib/python3.4/site-packages/django/core/management/__init__.py", line 303, in execute
settings.INSTALLED_APPS
  File "/usr/share/django-apps/virtualenv/lib/python3.4/site-packages/django/conf/__init__.py", line 48, in __getattr__
self._setup(name)
  File "/usr/share/django-apps/virtualenv/lib/python3.4/site-packages/django/conf/__init__.py", line 44, in _setup
self._wrapped = Settings(settings_module)
  File "/usr/share/django-apps/virtualenv/lib/python3.4/site-packages/django/conf/__init__.py", line 92, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/share/django-apps/virtualenv/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 2212, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  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 'mysite'

Upvotes: 1

Views: 494

Answers (1)

denvaar
denvaar

Reputation: 2214

You are most likely seeing this error because some environment variables are not set, or set incorrectly. I would check to make sure that your PYTHONPATH, and DJANGO_SETTINGS_MODULE are all pointing to the correct locations.

PYTHONPATH is used to specify additional directories for Python to look for things to use. I think you'll want to set it to the directory which contains your manage.py script.

However, you can do everything that you need to do with manage.py

Upvotes: 2

Related Questions