Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to import dash in python

I am unable to run any dash program. I get the error.

Dash was not successfully imported. Make sure you don't have a file named
'dash.py' in your current directory.

Also to check it out, I tried importing dash from python in terminal, surprisingly I can import dash in terminal where the directory don't contain .py file with dash import, whereas if any file contains import dash in it, I can't import dash in terminal in that directory. The attached picture will help you.Importing dash in two different terminals, in two different directories

like image 736
Mukul Sharma Avatar asked Sep 05 '18 16:09

Mukul Sharma


5 Answers

My problem was solved when i change the name of my file from test.py to test2.py, i hope it works for you.

like image 77
Alfredo Castaneda Avatar answered Oct 09 '22 20:10

Alfredo Castaneda


I faced the same exact error message, and I made sure there wasn't any dash.py file in the folder.

However, there was a plotly.py file and renaming it solved the problem for me.

like image 33
bangxiang Avatar answered Oct 09 '22 21:10

bangxiang


See this thread from the official Dash github repo. In my case, it was a file named test.py.

like image 40
coralvanda Avatar answered Oct 09 '22 21:10

coralvanda


To share my experience, I created a file named copy.py in my working directory - I know it is not the best name - and I started getting this issue. I was confused since I didn't install any new packages. Also, all other files in that directory, which used to work, stopped working and gave the same error about dash.

Renaming that file, copy.py to something else solved it for me. I am not sure if there's a list of preserved file names which will create this issue.

like image 1
see-king_of_knowledge Avatar answered Oct 09 '22 21:10

see-king_of_knowledge


Not sure if anyone will face it, basically I had it all working in Mac OS - Mojave, but after updating to Catalina "Dash was not successfully imported. Make sure you don't have a file named 'dash.py' in your current directory."

I can do import dash successfully at python prompt but strangely my program that worked fine in Mojave, threw above error.

I fixed it by

  1. pip uninstall dash
  2. pip install dash
like image 1
S N Avatar answered Oct 09 '22 21:10

S N