"PermissionError" 在输入 "exit()" 离开 Python 解释器时抛出
"PermissionError" thrown when typing "exit()" to leave the Python interpreter
当我使用 python
作为普通用户进入 python 解释器时。我看到这个:
Python 3.5.2 |Anaconda 4.1.1 (64-bit)| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
我可以立即输入 exit()
并且会发生这种情况:
>>> exit()
Error in atexit._run_exitfuncs:
PermissionError: [Errno 13] Permission denied
我认为可能与运行ning sudo python3
给出的事实有关:
Python 3.5.2 (default, Jul 5 2016, 12:43:10)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
这看起来是一个不同的 python 3.5 安装。
如果这是问题所在,我希望在输入 sudo python3
时让我的 anaconda python 安装 运行。我该怎么做?
用谷歌搜索错误消息后,我发现了这个问题:http://bugs.python.org/issue19891
似乎这个问题通常与当前用户没有主目录(我认为这对于名为 python 的用户来说是合乎逻辑的)或对其主目录没有适当的权限有关,但问题仍然存在。
将 ~/.python_history
的所有者从 root
更改为 my_user_account
解决了问题。
在 python3.4/3.5 上有同样的问题。我回去将 ~/.python_history 的所有权更改为我当前的用户,问题就消失了。
当我使用 python
作为普通用户进入 python 解释器时。我看到这个:
Python 3.5.2 |Anaconda 4.1.1 (64-bit)| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
我可以立即输入 exit()
并且会发生这种情况:
>>> exit()
Error in atexit._run_exitfuncs:
PermissionError: [Errno 13] Permission denied
我认为可能与运行ning sudo python3
给出的事实有关:
Python 3.5.2 (default, Jul 5 2016, 12:43:10)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
这看起来是一个不同的 python 3.5 安装。
如果这是问题所在,我希望在输入 sudo python3
时让我的 anaconda python 安装 运行。我该怎么做?
用谷歌搜索错误消息后,我发现了这个问题:http://bugs.python.org/issue19891
似乎这个问题通常与当前用户没有主目录(我认为这对于名为 python 的用户来说是合乎逻辑的)或对其主目录没有适当的权限有关,但问题仍然存在。
将 ~/.python_history
的所有者从 root
更改为 my_user_account
解决了问题。
在 python3.4/3.5 上有同样的问题。我回去将 ~/.python_history 的所有权更改为我当前的用户,问题就消失了。