question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tried to import 'plotly' but failed

See original GitHub issue

Expected behavior

Plot of param importances of optimized study.

Environment

  • Optuna version: 2.9.1
  • Python version: 3.8.5
  • OS: Windows 10
  • Plotly: 5.3.1

Error messages, stack traces, or logs

ImportError: Tried to import 'plotly' but failed. Please make sure that the package is installed correctly to use this feature. Actual error: No module named 'plotly'.
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
~\Anaconda3\lib\site-packages\optuna\visualization\_plotly_imports.py in <module>
      6 with try_import() as _imports:  # NOQA
----> 7     import plotly  # NOQA
      8     from plotly import __version__ as plotly_version

ModuleNotFoundError: No module named 'plotly'

The above exception was the direct cause of the following exception:

ImportError                               Traceback (most recent call last)
<ipython-input-46-ec7b157c78f5> in <module>
----> 1 optuna.visualization.plot_param_importances(study)

~\Anaconda3\lib\site-packages\optuna\visualization\_param_importances.py in plot_param_importances(study, evaluator, params, target, target_name)
     93     """
     94 
---> 95     _imports.check()
     96     _check_plot_args(study, target, target_name)
     97 

~\Anaconda3\lib\site-packages\optuna\_imports.py in check(self)
     84         if self._deferred is not None:
     85             exc_value, message = self._deferred
---> 86             raise ImportError(message) from exc_value
     87 
     88 

ImportError: Tried to import 'plotly' but failed. Please make sure that the package is installed correctly to use this feature. Actual error: No module named 'plotly'.

Steps to reproduce

  1. Create objective, optimize study
  2. Run optuna.visualization.plot_param_importances(study)

Additional context (optional)

This issue here https://github.com/optuna/optuna/issues/1339 has been closed but others have continued reporting similar issues.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
muzitachecommented, Apr 22, 2022

I still have same issue after reinstall plotly with conda. Importing plotly and checking version works well with import plotly and plotly.__version__

so I have been applying these fixes but didn’t work, turns out i needed to restart my system. This fixed my issue.

0reactions
cj2001commented, Aug 20, 2022

Bump!

Same problem here…

Read more comments on GitHub >

github_iconTop Results From Across the Web

ImportError: 'No module named plotly.plotly' in LinuxMint17.3
So Python was trying to import the module from the script file I was running. Doh! Renamed it and problem solved. Share.
Read more >
Failure at the first hurdle - Python error on "import plotly"
Hi there,. I've just started trying to use Plotly (and I'm a bit of a Python novice) following the instructions here: ...
Read more >
Troubleshooting in Python - Plotly
How to troubleshoot import and rendering problems in Plotly with Python. ... otherwise importing plotly can fail with mysterious error messages.
Read more >
Installing Plotly (ModuleNotFoundError: No module named ...
Well I have some new information. When I run import plotly in an IPython window via VS Code I get the same result...
Read more >
Module Not Found Error for plotly - Plotly Python
finally i found half of the answers . to resolve this issue you just need to install plotly packages in anaconda env. as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found