Anaconda3环境Python3.6.4中Plotly导入异常:无法导入exceptions
Hey there! Sorry to hear your Plotly import stopped working out of the blue. Let's walk through some steps to get it back up and running. First, let's recap your issue clearly:
You're using an Anaconda3-managed Python 3.6.4 environment, which worked fine with Plotly a few hours ago. Now running
import plotlythrows this error:import plotly Traceback (most recent call last): File "<ipython-input-1-6361d2547ebc>", line 1, in <module> import plotly File "C:\Users\janfe\Anaconda3\Lib\site-packages\plotly\plotly\plotly.py", line 30, in <module> from plotly import exceptions, files, session, tools, u...
This error usually pops up when there's a version mismatch between Plotly and your older Python 3.6.4 environment—newer Plotly versions (5.x and above) dropped support for Python 3.6. Here's how to fix it:
Step 1: Check your current Plotly version
Open your Anaconda prompt, activate your Python 3.6.4 environment withconda activate <your-env-name>, then run either:conda list plotlyor
pip show plotlyIf the version is 5.x or higher, that's definitely the problem.
Step 2: Uninstall the incompatible Plotly version
Depending on how you installed Plotly, run one of these commands:- For conda installations:
conda remove plotly --yes - For pip installations:
pip uninstall plotly --yes
- For conda installations:
Step 3: Install a Plotly version compatible with Python 3.6
Plotly 4.x series still supports Python 3.6. Install the latest compatible version with:pip install plotly==4.14.3If you prefer conda, you can search for the compatible version with
conda search plotlyand install the highest 4.x version available (likeconda install plotly=4.14.3).Step 4: Verify the fix
Open your IPython or Jupyter notebook again, runimport plotly, and it should work without errors.
If this doesn't fix it, double-check that no other package updates messed up your environment—sometimes conflicting dependencies can break imports. But downgrading Plotly to a 4.x version is the most likely solution here.
内容的提问来源于stack exchange,提问作者Jan Felix

