4

I am currently using RHEL7 and am trying to install matplotlib. When ever i have attempted to do

python -m pip install -U matplotlib

or

pip install matplotlib

I get the error message "Cannot uninstall 'pyparsing'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall."

Any help would be greatly appreciated, and if you need more information I can provide it.

Giddswindle
  • 185
  • 2
  • 3
  • 12
  • Try uninstalling `pyparsing` through `pip uninstall pyparsing`. Then try installing `matplotlib`. – Soumendra Dec 20 '18 at 15:45
  • It doesn't allow me to uninstall 'pyparsing' using pip either unfortunately. I got the same error code – Giddswindle Dec 20 '18 at 15:47
  • Are you using a [virtual environment](https://www.sitepoint.com/virtual-environments-python-made-easy/) to install `matplotlib`? If not please try. – Soumendra Dec 20 '18 at 15:49
  • Is the only way to use matplotlib with a virtual environment? – Giddswindle Dec 20 '18 at 15:54
  • Of course not the only way. – Soumendra Dec 20 '18 at 15:55
  • I'm trying to do this without using a virtual environment. I want to use python directly without using the virtual environment – Giddswindle Dec 20 '18 at 16:03
  • 1
    Apparently, someone even [made a video](https://www.youtube.com/watch?v=yxL5Dk3LYiM) on a possible workaround. – ImportanceOfBeingErnest Dec 20 '18 at 16:03
  • [This comment may be helpful](https://github.com/pypa/pip/issues/5247#issuecomment-381550610). – ImportanceOfBeingErnest Dec 20 '18 at 16:04
  • Did you install `pyparsing` via `yum`? What does `yum list installed | grep -i pyparsing` return? Also, what Python version is it (`python -V`)? – hoefling Dec 20 '18 at 20:36
  • When i attempt to install pyparsing via yum I get "Package pyparsing-1.5.6-9.e17.noarch already installed and latest version." And then the "yum list installed | grep - pyparsing" returns: pyparsing.noarch 1.5.6-9.el7 @anaconda/7.5 I don't want to be using the anaconda at all. I just want to use Python 3.7, but currently Python 2.7.5 and Python 3.7.1 are installed on my machine. – Giddswindle Dec 21 '18 at 13:15
  • Also @ImportanceOfBeingErnest I tried the workaround in the video and now i'm getting "error: command 'gcc' failed with exit status 1." – Giddswindle Dec 21 '18 at 13:55
  • Looks like `python` refers to Python 2.7.5 on your machine. If you need `matplotlib` for Python 2.7.5, install a more recent version of `pyparsing` as user, e.g.: `pip install --user "pyparsing==2.3.0"`. Now you should be able to install `matplotlib` as intended: `pip install --user matplotlib`. If you need it for Python 3.7, use the correct executable: `python3.7 -m pip install --user matplotlib`. – hoefling Dec 21 '18 at 16:38

1 Answers1

4

The problem is that pip cannot properly uninstall packages installed by "pure" distutils (see the details here).

You can fix the problem by deleting pyparsing by hands:

Firstly, you need to determine the path to the package:

$ pip list -v | grep pyparsing

You will see something like:

pyparsing           2.0.1              /path_to_the_python/site-packages

Then take this path and delete the package (mind the asterisk):

$ rm -rf  /path_to_the_python/site-packages/pyparsing*

And install it again:

$ pip install pyparsing
Yury Kirienko
  • 1,810
  • 1
  • 22
  • 32