Python-Modulpfad nicht gefunden

Python-Modulpfad nicht gefunden

Bei unserer OpenStack-Installation ist etwas schrecklich schiefgelaufen. Jetzt funktioniert Python nicht mehr richtig. Der Modulpfad wird nicht gefunden:

root@controller:/root# keystone token-get
Traceback (most recent call last):
  File "/usr/bin/keystone", line 6, in <module>
    from keystoneclient.shell import main
ImportError: No module named shell

Wenn ich den Modulpfad über die Umgebungsvariable hinzufüge, verschwindet dieser Fehler ... (der andere Fehler spielt im Moment keine Rolle)

root@controller:/root# export PYTHONPATH=/usr/lib/python2.7/dist-packages
root@controller:/root# keystone token-get
Authorization Failed: Unable to establish connection to http://controller:35357/v2.0/tokens

Merkwürdiges Detail: Auch ohne die Umgebungsvariable zu setzen, scheint python -m site den richtigen Pfad zu kennen:

sys.path = [
'/root',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
]
USER_BASE: '/root/.local' (doesn't exist)
USER_SITE: '/root/.local/lib/python2.7/site-packages' (doesn't exist)
ENABLE_USER_SITE: True

Da Python auch in Apache für das Dashboard nicht funktioniert, ist es keine Option, die Umgebungsvariable jedes Mal mit „export“ zu setzen. Wir müssen das Problem an anderer Stelle beheben.

Wo ist der Python-Include-Pfad konfiguriert?

AKTUALISIEREN:

Die Reihenfolge der Bibliothekspfade scheint wichtig zu sein. Das hier funktioniert:

PYTHONPATH=/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages; keystone token-get

und das funktioniert nicht:

PYTHONPATH=/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages; keystone token-get

Antwort1

export PYTHONPATH=/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages; keystone token-get

hat bei mir geklappt, danke

verwandte Informationen