在我们的Openstack安装上,有些出错了。现在python不再正常工作了。找不到模块路径:
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
如果我通过环境变量添加模块路径,则此错误消失...(此刻其他错误无关紧要)
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
奇怪的细节:即使没有设置环境变量,python -m网站似乎也知道正确的路径:
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
由于python在Apache中也不能用于仪表板,因此不能选择使用&#34; export&#34;来设置环境变量。每次。我们需要在其他地方解决问题。
python包括路径配置在哪里?
更新
lib路径的顺序似乎很重要。这是有效的:
PYTHONPATH=/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages; keystone token-get
这不起作用:
PYTHONPATH=/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages; keystone token-get
答案 0 :(得分:0)
根据您的发行版,有两个常见的地方:
添加export pythonpath=apath; another/one;
/etc/profile
中的将是系统范围内的
或~/.bash-profile
将是用户特定的