0

I know there is an answer to a similar question like this, but it won't help in my particular case. I wrote some python code for a client, and he can't get it to run in windows CMD. He has an error with matplotlib. The error is with the line "import matplotlib.pyplot as plt" and it says that matplotlib has no attribute 'get_data_path'. He isn't using conda or anything, just writing 'py program.py' to run the code. I've included a picture he sent me. Does anyone know what to do about this.

Screenshot showing issue:
enter image description here

4
  • 1
    Did you check AttributeError: module 'matplotlib' has no attribute 'get_data_path'? Did you try removing matplotlib and installing it again (preferably the latest version)? pip uninstall matplotlib? pip install matplotlib --upgrade? Commented Apr 26, 2021 at 16:57
  • I checked that, but it only had information for running in conda or other environments, not plain CMD. I'll try the reinstall thing though. Commented Apr 26, 2021 at 18:02
  • Ok, thanks. I ended up figuring it out though. I appreciate it. Commented Apr 26, 2021 at 22:48
  • Can you please tell me how did you figured it out? because I have similar problem and I could not solve it. and all other posts regarding this issue did not help me. @JosephWalker Commented Feb 6, 2023 at 21:11

3 Answers 3

3

I had the same issue. I tried all the above

pip uninstall matplotlib

pip install matplotlib --upgrade

I also tried

pip install matplotlib --user

Nothing worked so finally I created a new env and it worked only with the new env.

Sign up to request clarification or add additional context in comments.

Comments

2

I was getting the same error in Jupyter Notebook. Restarting the kernel made it work.

Comments

0

I encountered the same error when I am installing Matplotlib in my new environment in Anaconda, at the same line: "import matplotlib.pyplot as plt".

What I did to fix is to restart the jupyter kernel and re-run the code twice (1st time failed, second time passed), after I complete the matplotlib installation in anaconda prompt (with command: conda install -c conda-forge matplotlib, then fixed the issue "DLL load failed while importing _imaging" with conda update Pillow).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.