我得到了以下奇怪的没有权限python 中的问题,每当我以普通用户(非 root)身份登录(SSH)时都会发生这种情况:
Traceback (most recent call last):
File "/usr/lib/python2.7/site.py", line 562, in <module>
main()
File "/usr/lib/python2.7/site.py", line 544, in main
known_paths = addusersitepackages(known_paths)
File "/usr/lib/python2.7/site.py", line 271, in addusersitepackages
user_site = getusersitepackages()
File "/usr/lib/python2.7/site.py", line 246, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/usr/lib/python2.7/site.py", line 236, in getuserbase
USER_BASE = get_config_var('userbase')
File "/usr/lib/python2.7/sysconfig.py", line 543, in get_config_var
return get_config_vars().get(name)
File "/usr/lib/python2.7/sysconfig.py", line 442, in get_config_vars
_init_posix(_CONFIG_VARS)
File "/usr/lib/python2.7/sysconfig.py", line 321, in _init_posix
raise IOError(msg)
IOError: invalid Python installation: unable to open /usr/include/python2.7/pyconfig.h (Permission denied)
许可内容/usr/include/python2.7/pyconfig.h
如下:
-rw-r--r-- 1 根 根 35884 2011-10-04 17:24 /usr/include/python2.7/pyconfig.h
答案1
权限没问题,但恐怕如果你需要以普通用户身份打开它,你就必须更改权限。现在它的权限是 644 ( -rw-r--r--
),所以我会尝试将其设置为 645 ( -rw-r--r-x
):
sudo chmod 645 /usr/include/python2.7/pyconfig.h