collective / mr.bob

Mister Bob (the builder) is filesystem template renderer
http://mrbob.readthedocs.org/en/latest/
Other
69 stars 30 forks source link

exception with no readline on windows #34

Open rsyring opened 11 years ago

rsyring commented 11 years ago
C:\Users\rsyring\dev\projects\level12-src>mrbob --help
Traceback (most recent call last):
  File "c:\python27\scripts\mrbob-script.py", line 9, in <module>
    load_entry_point('mr.bob==0.1a7', 'console_scripts', 'mrbob')()
  File "c:\python27\lib\site-packages\distribute-0.6.25-py2.7.egg\pkg_resources.py", line 337, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "c:\python27\lib\site-packages\distribute-0.6.25-py2.7.egg\pkg_resources.py", line 2283, in load_entry_point
    return ep.load()
  File "c:\python27\lib\site-packages\distribute-0.6.25-py2.7.egg\pkg_resources.py", line 1993, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "c:\python27\lib\site-packages\mrbob\cli.py", line 11, in <module>
    from .configurator import Configurator
  File "c:\python27\lib\site-packages\mrbob\configurator.py", line 6, in <module>
    import readline
ImportError: No module named readline
rsyring commented 11 years ago

Fixed it with:

try:
    import readline
    readline  # make pyflakes happy, readline makes interactive mode keep history
except ImportError:
    # no readline on Windows
    pass

however, you could also require pyreadline when on windows and try that if the readline import fails.

http://stackoverflow.com/questions/6024952/readline-functionality-on-windows-with-python-2-7

domenkozar commented 11 years ago

Awesome, if you can make a patch that would prefer pyreadline and fallback to readline (also in setup.py, like other examples there), that would be awesome!

glenfant commented 8 years ago

A little bit more complicated than this.

Some Python / Linux distros (the ones that ship with CentOS IIRC) have no readline OTB.

On my Mac OSX box the stock Python 2.7 that ships with the OSX media has the readline module, when the one that comes with MacPorts have no readline module - unless you add it with "port install py27-readline".

On Windows, "pyreadline" works correctly with the ugly old console (cmd.exe) but AFAIK does not work correctly with Powershell or 3rd party consoles.

IMHO, the simples is the best. Readline is not essential to mrbob. Just use it if present or forget it otherwise.

The "emergency" is that the latest mr.bob does not work on Windows without a patch. The 2 minutes patch suggested by @rsyring works perfectly for me.

Thanks @domenkozar and hapPy new year to all.