0
votes

HI I am following an install from a book "Python Crash Course" chapter 15 which directed me to install matplotlib via downloading from pypi and using the format

python -m pip install --user matplotlib-2.2.2-cp36-cp36m-win32.whl

This seems to go ok but reports at the end.

File "C:\Program Files (x86)\Python Community\Python 3.6.1\lib\decimal.py", line 3 in , from decimal import * AttributeError: module 'numbers' has no attribute 'Number'

and when I enter an interactive shell:

import matplotlib

I get a ModuleNotFoundError

I have tried a matplotlib-2.2.2-cp36-cp36m-win32.whl and matplotlib-2.2.2-cp36-cp36m-win_amd64.whl both give the same error.

Could someone please let me know how to fix this?

5
looks like you are using matplotlib-2.2.2-cp36-cp36m-win32.whl as a value for your user argument (which is weird) - zar3bski
Are you using Python 2 or Python 3? - Rafael
I am using Python 3 - David Wigley
The issue is that you either have several versions installed or a broken version or incompatible versions. However, from the information given, how can anyone know? Try to make your case as reproducible for others as possible and check if the version you just installed is really the version you are running when getting the error. - ImportanceOfBeingErnest
I found it and sorry but it is obscure that I would never have know it was due to a file called numbers.py in my folder where I put my python files I renamed it and reinstalled matplotlib and it works now. I found it in here by doing a google search of the error and it found a similar issue on stackoverflow schoolboy error thanks for all the help. - David Wigley

5 Answers

1
votes

I am answering my own question.

The issue was to do with a file called numbers.py residing in a folder that I have all my python files, wheel files etc.

I found the answer in stack overflow. I will link to this matplotlib - AttributeError: module 'numbers' has no attribute 'Integral'.

The file was stopping the install so I renamed it and reinstalled matplotlib and it now works.

Sorry but this was not obvious to me !

0
votes

Try running cmd as administrator inside the python directory. Then execute:

pip3 install matplotlib-2.2.2-cp36-cp36m-win32.whl

Also make sure that you have all dependencies installed.

0
votes

The code seems very specific and something may not be supported any more.

You could first uninstall the current version using:

pip uninstall matplotlib

and then try installing matplotlib as follows:

pip install matplotlib

providing that you have admin rights to do so.

Then you can import as: import matplotlib.pyplot as plt

0
votes

It seems like you are installing the package on Python 2.

Try installing the library using:

py -3 -m pip install --user matplotlib

Assuming you are using Windows.

0
votes

Try doing as below:

python -m pip install --user matplotlib