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

Cannot get help in interactive help mode #173

Closed
rominf opened this issue Jan 10, 2014 · 5 comments
Closed

Cannot get help in interactive help mode #173

rominf opened this issue Jan 10, 2014 · 5 comments

Comments

@rominf
Copy link

rominf commented Jan 10, 2014

I use ipython3, open interactive mode (help()), type sh and ipython gives me an error:

Cannot import * from sh. Please import sh or import programs individually.
@deltab
Copy link

deltab commented May 21, 2014

This isn't limited to IPython either — the same thing happens with ordinary Python:

  • $ pydoc sh
  • >>> help('sh')
  • >>> import sh; help(sh)

@amoffat
Copy link
Owner

amoffat commented May 21, 2014

hmm...I'm thinking then the expected behavior is to print Docs: http://amoffat.github.io/sh/ since I can't really think of much meaningful help output in the terminal. The module exports only 2 names that aren't dynamic.

@amoffat
Copy link
Owner

amoffat commented Dec 29, 2014

fixed on branch release-1.10

@WaterSibilantFalling
Copy link

WaterSibilantFalling commented Jul 9, 2017

This is still a problem

  1. --- pydoc sh and >>>help(sh) should fail gracefully.
>>> help(sh)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    help(sh)
  File "/usr/lib/python2.7/dist-packages/bpython/curtsiesfrontend/_internal.py", lin
e 60, in __call__
    return super(_Helper, self).__call__(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/bpython/_internal.py", line 24, in __call__
    self.helper(*args, **kwargs)
  File "/usr/lib/python2.7/pydoc.py", line 1798, in __call__
    self.help(request)
  File "/usr/lib/python2.7/pydoc.py", line 1845, in help
    else: doc(request, 'Help on %s:')
  File "/usr/lib/python2.7/pydoc.py", line 1582, in doc
    pager(render_doc(thing, title, forceload))
  File "/usr/lib/python2.7/pydoc.py", line 1577, in render_doc
    return title % desc + '\n\n' + text.document(object, name)
  File "/usr/lib/python2.7/pydoc.py", line 361, in document
    if inspect.ismodule(object): return self.docmodule(*args)
  File "/usr/lib/python2.7/pydoc.py", line 1078, in docmodule
    all = object.__all__
  File "/home/me/.local/lib/python2.7/site-packages/sh.py", line 3349, in __getattr_
_
    return self.__env[name]
  File "/home/me/.local/lib/python2.7/site-packages/sh.py", line 3187, in __getitem_
_
    Please import sh or import programs individually.")
RuntimeError: Cannot import * from sh. Please import sh or import programs individua
lly.

and with pydoc

prompt> pydoc sh
Traceback (most recent call last):
  File "/usr/bin/pydoc", line 5, in <module>
    pydoc.cli()
  File "/usr/lib/python2.7/pydoc.py", line 2381, in cli
    help.help(arg)
  File "/usr/lib/python2.7/pydoc.py", line 1843, in help
    elif request: doc(request, 'Help on %s:')
  File "/usr/lib/python2.7/pydoc.py", line 1582, in doc
    pager(render_doc(thing, title, forceload))
  File "/usr/lib/python2.7/pydoc.py", line 1577, in render_doc
    return title % desc + '\n\n' + text.document(object, name)
  File "/usr/lib/python2.7/pydoc.py", line 361, in document
    if inspect.ismodule(object): return self.docmodule(*args)
  File "/usr/lib/python2.7/pydoc.py", line 1078, in docmodule
    all = object.__all__
  File "/home/me/.local/lib/python2.7/site-packages/sh.py", line 3349, in __getattr__
    return self.__env[name]
  File "/home/me/.local/lib/python2.7/site-packages/sh.py", line 3187, in __getitem__
    Please import sh or import programs individually.")
RuntimeError: Cannot import * from sh. Please import sh or import programs individually.

These are triggering the lines:

        # somebody tried to be funny and do "from sh import *"
        if k == "__all__":
            raise AttributeError("Cannot import * from sh. \
Please import sh or import programs individually.")

in /usr/lib//dist-packages/sh.py

(2) There IS help that should be presented upon help( sh ):

Tell the help()-seeking user that:

  • you access each and command by from sh import some-command e.g. from sh import pwd
  • each 'some-command' is now a function some-command() or some-command('dog', '--stop', '12) or pwd()
  • run an arbitrary executable by : import sh; cmd = sh.Command("/path/to/command"); cmd()
  • the command examples, only, from http://amoffat.github.io/sh/
  • and probably one or two more

That's what I reckon, anyway, as a novice user and all.

@amoffat amoffat reopened this Jul 9, 2017
@amoffat
Copy link
Owner

amoffat commented Apr 24, 2020

This is fixed by #455 and will go out with the next release

@amoffat amoffat closed this as completed Apr 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants