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

ModuleNotFoundError exception when IPython in not installed #1241

Closed
seisman opened this issue Apr 26, 2021 · 1 comment · Fixed by #1247
Closed

ModuleNotFoundError exception when IPython in not installed #1241

seisman opened this issue Apr 26, 2021 · 1 comment · Fixed by #1247
Labels
bug Something isn't working help wanted Helping hands are appreciated
Milestone

Comments

@seisman
Copy link
Member

seisman commented Apr 26, 2021

python ~/bad.py (this is the script posted above)
Traceback (most recent call last):
  File "/Users/pwessel/bad.py", line 2, in <module>
    import pygmt
  File "/Users/pwessel/GMTdev/pygmt/pygmt/__init__.py", line 28, in <module>
    from pygmt.figure import Figure, set_display
  File "/Users/pwessel/GMTdev/pygmt/pygmt/figure.py", line 9, in <module>
    import IPython
ModuleNotFoundError: No module named 'IPython'

Originally posted by @PaulWessel in #732 (comment)

@seisman
Copy link
Member Author

seisman commented Apr 26, 2021

pygmt/pygmt/figure.py

Lines 8 to 11 in 7466dc3

try:
import IPython
except KeyError:
IPython = None # pylint: disable=invalid-name

When IPython is not installed, it raises a ModuleNotFoundError exception, but the code incorrectly checks the KeyError exception.

We should fix it and ideally add a test.

@seisman seisman added bug Something isn't working help wanted Helping hands are appreciated labels Apr 26, 2021
@seisman seisman added this to the 0.4.0 milestone Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Helping hands are appreciated
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant