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: No module named 'psutil' #4867

Closed
emilykl opened this issue Nov 12, 2024 · 0 comments · Fixed by #4868
Closed

ModuleNotFoundError: No module named 'psutil' #4867

emilykl opened this issue Nov 12, 2024 · 0 comments · Fixed by #4868

Comments

@emilykl
Copy link
Contributor

emilykl commented Nov 12, 2024

Encountered this error today when calling fig.show() in a fresh Python environment:

ModuleNotFoundError: No module named 'psutil'

Stack trace:

(local) (plotly.py) (base) ekl@Emilys-MacBook-Air-2 plotly.py % python test-histogram.py
Traceback (most recent call last):
  File "/Users/ekl/code/plotly.py/test-histogram.py", line 17, in <module>
    fig.show()
  File "/Users/ekl/code/plotly.py/packages/python/plotly/plotly/basedatatypes.py", line 3414, in show
    return pio.show(self, *args, **kwargs)
           ^^^^^^^^
  File "/Users/ekl/code/plotly.py/packages/python/plotly/_plotly_utils/importers.py", line 36, in __getattr__
    class_module = importlib.import_module(rel_module, parent_name)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/Users/ekl/code/plotly.py/packages/python/plotly/plotly/io/_renderers.py", line 38, in <module>
    import psutil
ModuleNotFoundError: No module named 'psutil'

This is caused by the addition of import psutil at the top of plotly/io/_renderers.py in #4823.

I think all that needs to change is to move import psutil inside display_jupyter_version_warnings() under the two Jupyter elif cases (so that it doesn't get encountered when calling the normal fig.show() from a regular Python script).

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

Successfully merging a pull request may close this issue.

1 participant