Import plotly express error

Error when importing express:

import plotly.express as px

ImportError: cannot import name ‘qualitative’ from ‘plotly.express.colors’ (c:\program files\python\lib\site-packages\plotly\express\colors.py)

I’m using python 3.7 & jupyter notebook 6.0.0 (standalone, not Anaconda)
plotly - 4.0.0
plotly-express - 0.4.0

I tried reinstalling plotly but it’s not working… Any ideas ?

The resolve is :

pip install plotly --upgrade

Is working for me

Best regards

Hi,

I’m having the same problem. Can’t import plotly.express. Upgrading didn’t help since I’m using the latest version. note that I am only trying to import plotly.express.

My code used to work until last week but today I wanted to run it again and got this message. Can this be related to Windows settings change?

My Python version: Python 3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)] on win32

This is my virtual environment:

click==8.1.3
colorama==0.4.6
dash==2.8.1
dash-core-components==2.0.0
dash-html-components==2.0.0
dash-table==5.0.0
Flask==2.2.2
gunicorn==20.1.0
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.2
numpy==1.24.2
pandas==1.5.3
plotly==5.13.0
python-dateutil==2.8.2
pytz==2022.7.1
six==1.16.0
tenacity==8.2.1
Werkzeug==2.2.2

And this is the error I receive:

>>> import plotly.express
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\d33108\OneDrive\Projects\customers-dashboard\policies\Lib\site-packages\plotly\express\__init__.py", line 64, in <module>
    from . import data, colors, trendline_functions  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: cannot import name 'data' from partially initialized module 'plotly.express' (most likely due to a circular import) (C:\Users\d33108\OneDrive\Projects\customers-dashboard\policies\Lib\site-packages\plotly\express\__init__.py)

hi @parvizalizada ,
are you trying to import anything from within Plotly Express further down in your code?

What happens if you block all the code out and only import plotly.express as px? Do you get the same error?

Hi @adamschroeder

thanks for your reply. I did some troubleshooting as you suggest and found out that this problem was related to OneDrive synchronization. If I understand correctly, plotly express was trying to open some cached data but OneDrive has uploaded this data to the cloud and it was not present locally. For some reason, my local folder was not synchronized with the cloud. That’s why I was getting this error. At some point, I got OSError that gave me a hint where to look at.

Interesting. So what did you do to solve it?

I deleted my virtual environment and created it on another folder that is not linked with OneDrive. Now, there is no synchronization issue and I’m sure that this will not happen again.