Luiz Felipe Carneiro
Luiz Felipe Carneiro

Reputation: 31

problems in pip install and matplotlib library installation

to install matplotlib library its recomended uses this base:

python -m pip install -U pip
python -m pip install -U matplotlib

when I execute the following code:

(base) C:\WINDOWS\system32>python -m pip install -U pip

results in this warning:

 WARNING: Ignoring invalid distribution -atplotlib (c:\programdata\anaconda3\lib\site-packages)
 WARNING: Ignoring invalid distribution -atplotlib (c:\programdata\anaconda3\lib\site-packages)
 Requirement already satisfied: pip in c:\programdata\anaconda3\lib\site-packages (22.0.4)
 WARNING: Ignoring invalid distribution -atplotlib (c:\programdata\anaconda3\lib\site-packages)
 WARNING: Ignoring invalid distribution -atplotlib (c:\programdata\anaconda3\lib\site-packages)
 WARNING: Ignoring invalid distribution -atplotlib (c:\programdata\anaconda3\lib\site-packages)

so with -U matplotlib do:

WARNING: Ignoring invalid distribution -atplotlib (c:\programdata\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -atplotlib (c:\programdata\anaconda3\lib\site-packages)
Requirement already satisfied: matplotlib in c:\programdata\anaconda3\lib\site-packages (3.5.1)
Requirement already satisfied: numpy>=1.17 in c:\programdata\anaconda3\lib\site-packages (from matplotlib) (1.20.1)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\programdata\anaconda3\lib\site-packages (from matplotlib) (1.3.1)
Requirement already satisfied: pyparsing>=2.2.1 in c:\programdata\anaconda3\lib\site-packages (from matplotlib) (2.4.7)
Requirement already satisfied: packaging>=20.0 in c:\programdata\anaconda3\lib\site-packages (from matplotlib) (20.9)
Requirement already satisfied: fonttools>=4.22.0 in c:\programdata\anaconda3\lib\site-packages (from matplotlib) (4.29.1)
Requirement already satisfied: pillow>=6.2.0 in c:\programdata\anaconda3\lib\site-packages (from matplotlib) (8.2.0)
Requirement already satisfied: cycler>=0.10 in c:\programdata\anaconda3\lib\site-packages (from matplotlib) (0.10.0)
Requirement already satisfied: python-dateutil>=2.7 in c:\programdata\anaconda3\lib\site-packages (from matplotlib) (2.8.1)
Requirement already satisfied: six in c:\programdata\anaconda3\lib\site-packages (from cycler>=0.10->matplotlib) (1.15.0)
WARNING: Ignoring invalid distribution -atplotlib (c:\programdata\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -atplotlib (c:\programdata\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -atplotlib (c:\programdata\anaconda3\lib\site-packages)

and lastly, when I execute import matplotlib.pyplot as plt resuts in:

AttributeError                            Traceback (most recent call last)
<ipython-input-5-310f65eff20b> in <module>
      1 import networkx as nx
----> 2 import matplotlib.pyplot as plt
      3 import pandas as pd

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\__init__.py in <module>
    875 # triggering resolution of _auto_backend_sentinel.
    876 rcParamsDefault = _rc_params_in_file(
--> 877     cbook._get_data_path("matplotlibrc"),
    878     # Strip leading comment.
    879     transform=lambda line: line[1:] if line.startswith("#") else line,

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\cbook\__init__.py in _get_data_path(*args)
    478     return a file object, otherwise just a file path.
    479 
--> 480     Sample data files are stored in the 'mpl-data/sample_data' directory within
    481     the Matplotlib package.
    482 

AttributeError: module 'matplotlib' has no attribute 'get_data_path' 

I don't know what to do, hope you can help me.

Upvotes: 3

Views: 14766

Answers (4)

Foad S. Farimani
Foad S. Farimani

Reputation: 14008

Open terminal (i.e., cmd) and go to the problematic folder, in your case c:\programdata\anaconda3\lib\site-packages but on my computer c:\python310\lib\site-packages. Then remove all the directories starting with ~, in my case:

~ip
~ip-22.1.2.dist-info

using the command from here:

for /f %i in ('dir /a:d /s /b ~*') do rd /s /q %i

then try upgrading pip again to be sure things are OK now:

python -m pip install -U pip

interestingly enough, I had the same issue on my macOS device as well on the /usr/local/lib/python3.10/site-packages, and the problematic folders being

~BB
~BB-0.2-py3.10.egg-info

I could easily remove them by going to the said folder and running

rm -rf ~*

Upvotes: 0

ahruf
ahruf

Reputation: 11

Whether you encounter this problem when trying to install matplotlib or sqlalchemy the fix is simple and the same.

Try locating the folder it returns, (c:\python310\lib\site-packages) and delete any folder starting with ~

Upvotes: -1

zain.py
zain.py

Reputation: 191

Go to the location in the warning and look for folders starting with "~", if you find any, delete them and rerun the code.

Upvotes: 12

Toby
Toby

Reputation: 96

It seems like you may have installed it incorrectly. Try executing

pip show matplotlib

Does it show the version installed?

If you are using anaconda, it should be installed through

conda install matplotlib

Upvotes: 1

Related Questions