I have installed matplotlib on a Windows 10 machine using
pip3 install matplotlib
I get a message that it's using the wheel
matplotlib-3.4.1-cp39-cp39-win_amd64.whl1
When I type import matplotlib in a python 3.9 shell, I get the following message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python39\lib\site-packages\matplotlib\__init__.py", line 107, in <module>
from . import _api, cbook, docstring, rcsetup
File "C:\Python39\lib\site-packages\matplotlib\rcsetup.py", line 26, in <module>
from matplotlib.colors import Colormap, is_color_like
File "C:\Python39\lib\site-packages\matplotlib\colors.py", line 82, in <module>
from matplotlib import _api, cbook, scale
File "C:\Python39\lib\site-packages\matplotlib\scale.py", line 18, in <module>
from matplotlib.ticker import (
File "C:\Python39\lib\site-packages\matplotlib\ticker.py", line 179, in <module>
from matplotlib import transforms as mtransforms
File "C:\Python39\lib\site-packages\matplotlib\transforms.py", line 46, in <module>
from matplotlib._path import (
ImportError: DLL load failed while importing _path: The specified module could not be found.
I ran the installation under Windows Terminal, as an administrator.
How can I fix this? I don't want to install anaconda or WinPython, if I can avoid it. I just want matplotlib to work.
This issue is present again with matplotlib 3.3.2, 3.3.3 and 3.3.4. .
matplotlib 3.3.0 3.3.1 work.
I found a solution by mkunzBGC on Github:
https://github.com/matplotlib/matplotlib/issues/18292#issuecomment-792634734
The downgrade to matplotlib 3.3.1 worked for me.
I figured it out. If you have already installed matplotlib, but the error still comes about. Then you have to download Microsoft C++ from their website. https://www.microsoft.com/en-US/Download/confirmation.aspx?id=48145
install Microsoft c++ then you can try again to run your code. it has worked for me like magic. I got the solution from a youtube video.
link here. https://www.youtube.com/watch?v=DpwsvUkNAmg
Related
I have strange issue while loading matplotlib package. Never observed that before. The package is trying to load PIL from the wrong place. If I try to load PIL from the command line, it also loaded from the wrong place.
Here is matplotlib traceback:
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/XXX/python_rep/miniconda3/envs/work/lib/python3.9/site-packages/matplotlib/__init__.py", line 113, in <module>
from . import _api, _version, cbook, _docstring, rcsetup
File "/home/XXX/python_rep/miniconda3/envs/work/lib/python3.9/site-packages/matplotlib/rcsetup.py", line 27, in <module>
from matplotlib.colors import Colormap, is_color_like
File "/home/XXX/python_rep/miniconda3/envs/work/lib/python3.9/site-packages/matplotlib/colors.py", line 51, in <module>
from PIL import Image
File "/homeappl/common-software/sw/python3.6/lib/python3.6/site-packages/PIL/Image.py", line 69, in <module>
from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL' (/homeappl/common-software/sw/python3.6/lib/python3.6/site-packages/PIL/__init__.py)
Please note that I use my own conda environment with python 3.9
It is activated and contained Pillow version 9.0.0
Other packages are loaded from that instance, but bloody PIL tries to reach the common area.
/home/XXX/python_rep/miniconda3/envs/work/bin/python3.9 -m pip install pillow
Requirement already satisfied: pillow in /homeappl/common-software/sw/python3.6/lib/python3.6/site-packages (7.0.0)
I have no idea why it tries to load package from old place. But I do not have access to that - due to admin rights.
How to force machine not to use wrong package?
I installed librosa, and now im trying to import it
import librosa
This throws me this error for some reason
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\__init__.py", line 12, in <module>
from . import core
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\core\__init__.py", line 125, in <module>
from .time_frequency import * # pylint: disable=wildcard-import
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\core\time_frequency.py", line 11, in <module>
from ..util.exceptions import ParameterError
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\util\__init__.py", line 77, in <module>
from .utils import * # pylint: disable=wildcard-import
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\util\utils.py", line 15, in <module>
from .decorators import deprecated
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\util\decorators.py", line 9, in <module>
from numba.decorators import jit as optional_jit
ModuleNotFoundError: No module named 'numba.decorators'
Why am i getting this error even after installing the library?
You have to install numbra version 0.48 because of a bug, run
pip install numba==0.48
Librosa Issue on Github
You need to use any numba version before 0.8.0
However, the most recent librosa is not compatible with any numba below 0.48.
At least, that's what I've found from using it on Windows. My solution was to use google colaboratory as it didn't give me any error when importing librosa.
I've got the exact error. Solved it with
pip uninstall --yes librosa
pip install librosa --force-reinstall
Your python version should be 3.8.
I recently updated my Ubuntu to 18.04 and now when using Python (2.7) I cannot import matplotlib anymore. Error when importing:
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "~/.local/lib/python2.7/site-packages/matplotlib/__init__.py", line 131, in <module>
from matplotlib.rcsetup import defaultParams, validate_backend, cycler
File "~/.local/lib/python2.7/site-packages/matplotlib/rcsetup.py", line 29, in <module>
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
File "~/.local/lib/python2.7/site-packages/matplotlib/fontconfig_pattern.py", line 28, in <module>
from backports.functools_lru_cache import lru_cache
ImportError: No module named functools_lru_cache
I installed matplotlib via
pip install --user matplotlib
Like matplotlib, functools_lru_cache-module is installed in
~/.local/lib/python2.7/site-packages
What am I missing here?
I tried uninstalling and reinstalling the "functools_lru_cache" module as suggested here:
python 2.7 functools_lru_cache does not import although installed
but that didn't help. Still same error.
Uninstalling matplotlib via pip and installing an older version (2.0.2) fixed this for me. See: https://stackoverflow.com/a/49335954/1627966
I'm going through the API tutorial on New Coder (this one) and got the following error when I try to run the program:
RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9Traceback (most recent call last):
File "api.py", line 7, in <module>
import matplotlib.pyplot as plt
File "/home/crash/TestEnv/venv/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 27, in <module>
import matplotlib.colorbar
File "/home/crash/TestEnv/venv/local/lib/python2.7/site-packages/matplotlib/colorbar.py", line 32, in <module>
import matplotlib.artist as martist
File "/home/crash/TestEnv/venv/local/lib/python2.7/site-packages/matplotlib/artist.py", line 12, in <module>
from .transforms import Bbox, IdentityTransform, TransformedBbox, \
File "/home/crash/TestEnv/venv/local/lib/python2.7/site-packages/matplotlib/transforms.py", line 39, in <module>
from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: numpy.core.multiarray failed to import
I know it isn't my code because I tried running it with the example code too and had the same issue. One answer I saw suggested on here was to try Numpy 1.8, but that didn't work either.
Also, all of this is set up within a virtual environment as directed so I don't think it's an issue of what I have installed elsewhere.
Installing packets from file with requirements may cause failures. I mean something like pip install -r requirements.txt
It seems to me that pip just installs packets in order without dependencies (first line from file, second line, ...).
I had same issue because of having installed numpy outside of environment and numpy after matplotlib in requirements.txt Pip compiled matplotlib with system nympy, after that it installed new numpy and nothing worked.
I just have switched strings and set matplotlib after numpy. Now it works.
Try this:
pip install numpy --upgrade
It works for me
I try to plot a simple graph in networkx, but this error message appears:
RuntimeError: module compiled against API version 6 but this version of numpy is 4
Traceback (most recent call last):
File "D:\project\awk\gg.py", line 2, in <module>
import matplotlib.pyplot as plt
File "D:\programs\python\lib\site-packages\matplotlib\pyplot.py", line 26, in <module>
from matplotlib.figure import Figure, figaspect
File "D:\programs\python\lib\site-packages\matplotlib\figure.py", line 24, in <module>
import matplotlib.artist as martist
File "D:\programs\python\lib\site-packages\matplotlib\artist.py", line 7, in <module>
from transforms import Bbox, IdentityTransform, TransformedBbox, \
File "D:\programs\python\lib\site-packages\matplotlib\transforms.py", line 35, in <module>
from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: numpy.core.multiarray failed to import
How do I solve this?
You downloaded a binary version of matplotlib linked/compiled against a newer version of numpy than you have installed.
Either upgrade your numpy installation, find a version of matplotlib compiled against your version of numpy, or build matplotlib from the source.
The problem is with the API mismatch as stated in the error message. First of all use pip to uninstall numpy.
pip uninstall numpy
Then get the latest binary installer for numpy and matplotlib from here selecting your version of python and windows 32 or 64 bit. Then install it as normal software installer. Make sure it finds your version of python during the installation. This is it !!