Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"ValueError: _type_ 'v' not supported" error after installing PyReadline

After I installed PyReadline, IPython won't work. When I uninstalled it, it starts working again.

The stack trace for 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
like image 486
thinkdeeper Avatar asked Sep 16 '15 12:09

thinkdeeper


2 Answers

As stated on their site, the PyReadline library is Used for Windows.

Looking at the last lines of your stack trace:

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

It is trying to import windows specific data types from ctypes which is obviously not possible since you are not running Windows.

like image 139
Dimitris Fasarakis Hilliard Avatar answered Nov 19 '22 06:11

Dimitris Fasarakis Hilliard


This will likely help exactly no one in the year 2020 or beyond, but all the same I want to record it here for posterity.

I experienced the same ValueError: _type_ 'v' not supported traceback with an installation of Python 2.7.16 in an HPC cluster environment, attempting to install pdbpp, which depends on fancycompleter, which depends on pyreadline, which imports ctypes.wintypes and is affected by this this core Python issue from 2012.

It's true that ctypes.wintypes should never be imported on a non-Windows platform (Cygwin, MSYS2, and Git Bash are technically non-Windows, since they will have a real GNU Readline library and don't need the pure Python shim).

However if it were imported on a non-Windows platform, because of the issue mentioned above, ctypes.wintypes throws a ValueError instead of an ImportError, which means that a typical try/except that expects to catch an ImportError will just blow up because of the unhandled exception.

Pdbpp's fancycompleter, or rather pyreadline, somehow fell victim to this. I get confused about who's to blame, because fancycompleter's setup.py isn't supposed to bring in pyreadline as a dependency except on Windows, but somehow there it was on my Linux system. And if it's there, fancycompleter tries to import it.

All I can figure is I may have had an old fancycompleter in my pip cache with a typo in its setup.py that was pulling in pyreadline when it shouldn't have, because it was grabbing that dependency, time after time.

What actually finally resolved this situation for me was to pip uninstall pyreadline, then pip install -U --ignore-installed --no-cache-dir fancycompleter to get a "fresh" version of fancycompleter that did not bring in the unnecessary pyreadline dependency.

like image 44
TheDudeAbides Avatar answered Nov 19 '22 07:11

TheDudeAbides