Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"pdoc IPython" fails #109

Closed
hbredin opened this issue Jul 19, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@hbredin
Copy link

commented Jul 19, 2016

I was trying to run pdoc on one of my module (pyannote.core) and it failed.

I think I narrowed the problem down to this:

$ pip install ipython
$ pip install pdoc
$ pdoc IPython
Traceback (most recent call last):
  File "[REDACTED]/bin/pdoc", line 477, in <module>
    module = pdoc.import_module(args.module_name)
  File "[REDACTED]/lib/python2.7/site-packages/pdoc/__init__.py", line 326, in import_module
    __import__(module_name)
  File "[REDACTED]/lib/python2.7/site-packages/IPython/__init__.py", line 49, in <module>
    from .terminal.embed import embed
  File "[REDACTED]/lib/python2.7/site-packages/IPython/terminal/embed.py", line 17, in <module>
    from IPython.terminal.interactiveshell import TerminalInteractiveShell
  File "[REDACTED]/lib/python2.7/site-packages/IPython/terminal/interactiveshell.py", line 77, in <module>
    _is_tty = (sys.stdin.isatty()) and (sys.stdout.isatty()) and  (sys.stderr.isatty())
ValueError: I/O operation on closed file

If that helps, here is my config:

$ python --version
Python 2.7.10
$ pip freeze
appnope==0.1.0
backports.shutil-get-terminal-size==1.0.0
decorator==4.0.10
ipython==5.0.0
ipython-genutils==0.1.0
Mako==1.0.4
Markdown==2.4.1
MarkupSafe==0.23
pathlib2==2.1.0
pdoc==0.3.2
pexpect==4.2.0
pickleshare==0.7.3
prompt-toolkit==1.0.3
ptyprocess==0.5.1
Pygments==2.1.3
simplegeneric==0.8.1
six==1.10.0
traitlets==4.2.2
wcwidth==0.1.7
wheel==0.24.0
@BurntSushi

This comment has been minimized.

Copy link
Contributor

commented Jul 19, 2016

pdoc has to actually import the module in order to document it. I don't know for sure, but judging by the traceback, it looks like ipython is trying to do things upon import which doesn't make sense in this context. pdoc is really only meant for idiomatic Python, and running code at import isn't idiomatic.

I think it would be better to focus on the error for your particular module rather than ipython. Of course, if your module is importing ipython, then I don't think there's much that can be done other than hacks like wrapping import ipython in a try...except or something.

@hbredin

This comment has been minimized.

Copy link
Author

commented Jul 19, 2016

Wrapping the faulty import in a try... except made the trick.
Thanks for the quick answer.

@hbredin hbredin closed this Jul 19, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.