When i try to run a python script in which i do an import statement matplotlib.patheffects, i get an error message saying there is no module called patheffects.
the statement is
import matplotlib.patheffects
Kindly help me to figure out the reason for this error and how to make the code run without this glitch.
import matplotlib.patheffects works perfectly well for me. Please make sure you have matplotlib installed. The most current version is 1.0.1. You can download from here.
Matplotlib depends on numpy, so make sure you have it installed before installing matplotlib.
Also check out the tips on installing matplotlib.
Related
I have a Python program that has the following import command:
import matplotlib.pyplot as plt
and on line:
ax.imshow(worldmap, cmap=plt.cm.cmapname)
throws the following error:
<module>
ax.imshow(worldmap, cmap=plt.cm.cmapname)
AttributeError: module 'matplotlib.cm' has no attribute 'cmapname'
The matplotlib library was installed with pip install matplotlib.
Strangely, this same program runs on another person's PC with no problem, and he has never seen this error before. Would anyone know what is causing this error and how to fix it?
I'm running Python 3.9.1. I'm wondering if we might be using different versions of matplotlib and whether this might be an issue.
Ali Irani had the right answer. I was using Python 3.9.5 with matplotlib 3.4.2, and my friend was using Python 3.7.1 with matplotlib 3.0.3. I installed what my friend was using, and his code worked. By the way: I first tried installing matplotlib with Python 3.9.5, and it wouldn't install. It seems that successive matplotlib versions are not upwardly compatible. Really, you would expect that whatever worked with older versions should also work with newer versions, but this evidently is not the case.
I'm using a remote machine for computation and data analysis. I don't have sudo access in this machine, for data analysis purposes I want to use python libraries such as vtk etc since pip is not installed in this machine, I set up a 'virtual-environment' and install VTK there,
I used the method explained here (https://stackoverflow.com/a/13958308/10755782). Then I could install vtk in the virtual environment using pip.
But now the problem is that I can't import matplotlib.pyplot, it is giving me the error
ImportError: No module named Tkinter.
This error is strange because matplotlib.pyplot works in this particular system outside my virtual-environment. There are a few workarounds to start using matplotlib.pyplot without tkinter such as this (https://stackoverflow.com/a/49988926/10755782), but this is not helpfull in my case as this machine is remote-accessed and I need 'tkinter' to view the graphs on my screen.
I tried installing 'tkinter' inside my virtual-env, but I could not ( since we can't install 'tkinter' with pip and I don't have sudo access).
As I could not find any immediate solution to this problem anywhere I tried to fix this myself and I did the following,
inside my virtual environment, the version of matplotlib was 2.2.4 and outside it was 1.2.0 ( which is working fine). So I downgraded the version of matplotlib inside my virtual environment to 1.2.0
pip install 'matplotlib==1.2.0' --force-reinstall
now I have the same version of matplotlib inside and outside the virtual env. But now, when I try import matplotlilb.pyplot as plt I'm getting the error
ImportError: /b/home/ipcms/rcheenik/Python_virt-env/python2.7/my_new_env/lib/python2.7/site-
packages/matplotlib/_cntr.so: undefined symbol: _intel_fast_memset
Is there any way to fix this ^^ error? any of these following will be able to help me.
without OR is there any way to install tkinter without sudo ? or inside the 'virtual-environment' ?
OR is there any alternatives to matplotlib.pyplot which works without 'tkinter' and still display graphs remotely? ( not favourable, as I have to rewrite the entire code )
Thanks in advance for the help.
I found this answer to a similar question however, which I believe would solve your issue.
https://stackoverflow.com/a/49988926/8775307
It imports matplotlib.pyplot without tkinter. I don't know if all the features are actually included though, so you'll have to test and let us know :).
You could always write to the administrator and request Tkinter - it's a widely used and useful package, so they might be willing to include it.
I am using python version 3.6.2 and working on image processing. My problem is when I run python through cmd it imports io module of skimage without error but when I import it through python Idle it shows module error that no module name io. Can anyone please enlighten me why is this happening? For more understanding i'm putting screenshots of both the cases.
Through cmd:
Through Python Idle:
This problem got solved by reinstalling each and every supporting package.
I want to plot some GPS-data using python 2.7 using matplotlibs basemap.
I download the binary windows installer and it executes and run without any problems. However, when I try to import and run in python I get:
from mpl_toolkits.basemap import basemap
ImportError: No module named basemap
I tried the
python setup.py
and
pip install basemap-1.0.8-cp27-none-win_amd64
in prompt which seems to be succesful.
GEOS, which is a dependency should be involved in the Basemap installer but I installed OSGeo4w64 separately to make sure geos_c and init is in place.
I hope someone can help me out. This feels like it is well above my level.
I have ofcourse looked through other threads on this page, but none of them seem to offer a solution.
Best regards
Instead of this:
from mpl_toolkits.basemap import basemap
do this:
from mpl_toolkits.basemap import Basemap
Check this as well.
I'm involved in a raspberry pi project and I use python language. I installed scipy, numpy, matplotlib and other libraries correctly. But when I type
from scipy.io import wavfile
it gives error as "ImportError: No module named scipy.io"
I tried to re-install them, but when i type the sudo cord, it says already the new version of scipy is installed. I'm stucked in this point and please help me... Thank you
I would take a guess and say your Python doesnt know where you isntalled scipy.io. add the scipy path to PYTHONPATH.