On our Openstack installation somethin awfully went wrong. Now python does not work properly any more. The module path is not found:
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
If I add the module path via environment variable, this error disappears... (the other error does not matter in the moment)
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
Odd detail: Even without setting the environment variable python -m site seems to know the right path:
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
As python also does not work in Apache for the dashboard, it is not an option to set the environment variable with "export" every time. We need to fix the problem elsewhere.
Where is the python include path configured?
UPDATE:
The order of the lib paths seems to matter. This is working:
PYTHONPATH=/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages; keystone token-get
and this is not working:
PYTHONPATH=/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages; keystone token-get
Depending on your distro, two common places :
add export pythonpath=apath; another/one;
export pythonpath=apath; another/one;
in /etc/profile
will be system-wide or ~/.bash-profile
will be user-specific
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.