2016-07-27 14 views
0

I verwenden Django 1,9 nach 1,8 Django aktualisieren und, wenn i Befehl eingebenpkg_resources.DistributionNotFound: Django == 1.8.3 in Django 1.9

django-admin runserver 

Ich habe diese einen Fehler:

Traceback (most recent call last): 
    File "/usr/local/bin/django-admin", line 5, in <module> 
    from pkg_resources import load_entry_point 
    File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2749, in <module> 
    working_set = WorkingSet._build_master() 
    File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 446, in _build_master 
    return cls._build_from_requirements(__requires__) 
    File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 459, in _build_from_requirements 
    dists = ws.resolve(reqs, Environment()) 
    File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 628, in resolve 
    raise DistributionNotFound(req) 
pkg_resources.DistributionNotFound: Django==1.8.3 

Und dann versuche ich diesen einen Befehl eingeben:

django-admin.py runserver 

ich diese Fehlermeldung anzeigt:

Traceback (most recent call last): 
    File "/usr/local/bin/django-admin.py", line 5, in <module> 
    management.execute_from_command_line() 
    File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 353, in execute_from_command_line 
    utility.execute() 
    File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 345, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 195, in fetch_command 
    klass = load_command_class(app_name, subcommand) 
    File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 39, in load_command_class 
    module = import_module('%s.management.commands.%s' % (app_name, name)) 
    File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
    File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 16, in <module> 
    from django.db.migrations.executor import MigrationExecutor 
    File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 7, in <module> 
    from .loader import MigrationLoader 
    File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 10, in <module> 
    from django.db.migrations.recorder import MigrationRecorder 
    File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 12, in <module> 
    class MigrationRecorder(object): 
    File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 26, in MigrationRecorder 
    class Migration(models.Model): 
    File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 27, in Migration 
    app = models.CharField(max_length=255) 
    File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", line 1072, in __init__ 
    super(CharField, self).__init__(*args, **kwargs) 
    File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", line 166, in __init__ 
    self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE 
    File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 55, in __getattr__ 
    self._setup(name) 
    File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 41, in _setup 
    % (desc, ENVIRONMENT_VARIABLE)) 
django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. 

Ich versuche, Django zu deinstallieren und zu installieren. Aber ich habe immer noch diese Fehler. Hoffe jemand kann mir dabei helfen. Danke

+0

Haben Sie sowohl 'pip' als auch' easy_install' verwendet, um Ihre Pakete zu verwalten? Wenn ja, dann kann die Antwort auf [diese Frage] (http://stackoverflow.com/questions/6200056/pip-broke-how-to-fix-distributionnotfound-error) hilfreich sein. – rafalmp

Antwort

2

Normalerweise sollten Sie django-admin nicht verwenden, außer wenn Sie django-admin startproject tun.

Nachdem Sie das Projekt erstellt haben, ist es einfacher, manage.py zu verwenden, um den Dev-Server auszuführen, da es die Einstellung des Pfad- und Einstellungsmoduls für Sie übernimmt.

./manage.py runserver 

Weitere Informationen finden Sie unter the docs.

0

Vielleicht haben Sie eine andere Python-Version verwendet? Es ist Python 2.7 jetzt, und es scheint, dass Sie Django nicht richtig für Python2.7 installiert haben. Sie können für die Verwendung von python3 in ubuntu

python3 manage.py runserver 

versuchen (es ist standardmäßig und accessibler mit python3 installiert ist), oder versuchen, zu definieren, wie es mit einer anderen Python-Version laufen.

+0

Wenn ich versuche, 'python3 manage.py run server' zu verwenden, habe ich' ImportError: Kein Modul namens 'django'' –

+0

Nun, ich scheiterte. Dann können Sie versuchen, festzustellen, ob es korrekt installiert ist, und zuerst Ihre env-Variablen überprüfen. Es gibt eine nahe Frage: http://stackoverflow.com/questions/8712371/pkg-resources-distributionnotfound-django-1-3-1-which-crating-a-new-project-in. Probieren Sie es aus und sagen Sie, ob es Ihr Problem löst – birdy90