安装PyReadline后,IPython无法正常工作。当我卸载它时,它再次开始工作。
ipython的堆栈跟踪:
(py2.7_monitor)[root@vm10-136-8-98 monitor]# ipython
WARNING: IPython History requires SQLite, your history will not be saved
Traceback (most recent call last):
File "/home/py2.7_monitor/bin/ipython", line 11, in <module>
sys.exit(start_ipython())
File "/home/py2.7_monitor/lib/python2.7/site-packages/IPython/__init__.py", line 118, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "/home/py2.7_monitor/lib/python2.7/site-packages/traitlets/config/application.py", line 591, in launch_instance
app.initialize(argv)
File "<string>", line 2, in initialize
File "/home/py2.7_monitor/lib/python2.7/site-packages/traitlets/config/application.py", line 75, in catch_config_error
return method(app, *args, **kwargs)
File "/home/py2.7_monitor/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 314, in initialize
self.init_shell()
File "/home/py2.7_monitor/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 330, in init_shell
ipython_dir=self.ipython_dir, user_ns=self.user_ns)
File "/home/py2.7_monitor/lib/python2.7/site-packages/traitlets/config/configurable.py", line 380, in instance
inst = cls(*args, **kwargs)
File "/home/py2.7_monitor/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 531, in __init__
self.init_readline()
File "/home/py2.7_monitor/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 1941, in init_readline
import IPython.utils.rlineimpl as readline
File "/home/py2.7_monitor/lib/python2.7/site-packages/IPython/utils/rlineimpl.py", line 21, in <module>
_rl = __import__(_rlmod_name)
File "/home/py2.7_monitor/lib/python2.7/site-packages/readline.py", line 6, in <module>
from pyreadline.rlmain import Readline
File "/home/py2.7_monitor/lib/python2.7/site-packages/pyreadline/__init__.py", line 12, in <module>
from . import logger, clipboard, lineeditor, modes, console
File "/home/py2.7_monitor/lib/python2.7/site-packages/pyreadline/clipboard/__init__.py", line 13, in <module>
from .win32_clipboard import GetClipboardText, SetClipboardText
File "/home/py2.7_monitor/lib/python2.7/site-packages/pyreadline/clipboard/win32_clipboard.py", line 37, in <module>
import ctypes.wintypes as wintypes
File "/usr/local/lib/python2.7/ctypes/wintypes.py", line 23, in <module>
class VARIANT_BOOL(_SimpleCData):
ValueError: _type_ 'v' not supported
答案 0 :(得分:8)
As stated在其网站上,PyReadline
库用于 Windows 。
查看堆栈跟踪的最后几行:
import ctypes.wintypes as wintypes
File "/usr/local/lib/python2.7/ctypes/wintypes.py", line 23, in <module>
class VARIANT_BOOL(_SimpleCData):
ValueError: _type_ 'v' not supported
它正试图从ctypes
导入特定于Windows的数据类型,这显然是不可能的,因为您没有运行Windows。
答案 1 :(得分:0)
这可能在2020年或之后完全没有帮助,但我想在此记录下来以供后代使用。
在HPC集群环境中安装Python 2.7.16时,我经历了相同的ValueError: _type_ 'v' not supported
追溯,试图安装pdbpp,它取决于fancycompleter,后者取决于pyreadline,从2012年开始导入ctypes.wintypes
并受此this core Python issue的影响。
的确,ctypes.wintypes
绝对不能在非Windows平台上导入(Cygwin,MSYS2和Git Bash从技术上讲非Windows,因为它们将具有 real GNU Readline库,不需要纯粹的Python填充程序。
但是,如果 是在非Windows平台上导入的,则由于上述问题,ctypes.wintypes
会抛出ValueError
而不是ImportError
,这意味着由于未处理的异常,期望捕获try
的典型except
/ ImportError
会爆炸。
Pdbpp的fancycompleter或pyreadline在某种程度上成为了受害者。我对应该责怪谁感到困惑,因为fancycompleter的setup.py
不应引入pyreadline作为依赖项except on Windows,但是在Linux系统上确实存在。并且如果在那,fancycompleter尝试导入它。
我能确定的是,我的点子缓存中可能有一个旧的fancycompleter,其setup.py
中有一个错字,该错字在不应该的情况下拉入pyreadline,因为它是 一次又一次地抓住这种依赖。
最终真正为我解决了这种情况的方法是先pip uninstall pyreadline
,然后pip install -U --ignore-installed --no-cache-dir fancycompleter
,以获得“新”版本的fancycompleter,该版本没有带来不必要的pyreadline依赖性。