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.
Related
I want to compile a python file to a standalone .exe programm using pyinstaller onefile. Running the python file, everything works fine, but running the .exe file, it throws the exception
ModuleNotFoundError: No module named 'matplotlib.backends.backend_svg'
I am using schemdraw,
and schemdraw uses matplotlib.
Because I dont want matplotlib to open a window everytime I export an svg I use the backend "Agg" with matplotlib.
import matplotlib.backends.backend_tkagg
import matplotlib
matplotlib.use('Agg')
I of course have tried reinstalling matplotlib
Using instead of pyinstaller --onefile <file> pyinstaller <file>
I tried putting import matplotlib.backends.backend_tkagg over import matplotlip
upgrading matplotlib pip install matplotlib --upgrade --user
basicly this post. But since this isn't exactly my problem and none of it worked I am asking here
Thanks in advance
Do you need to use Matplotlib for anything other than schemdraw? If not, you can set schemdraw to draw straight to SVG:
schemdraw.use('svg')
then it won't even go through Matplotlib.
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 have an application in python2.7 which runs fine.
Because i wanted to run it on a different laptop,i installed the matplotlib1.1 .
The problem is that the application finishes but no plot window exists.
Problem with Gtk or Tk? I tried to do in the matplotlibrc file "backend:TkAgg" or "GtkAgg" but still the same.
I forgot to mention that the laptop runs linux.
----------EDIT-------------------
I tried the installation again and it shows a message:
You may need to define display for tk to work so that setup can
determine where your libraries are located.Tkinter present but header
files are not found.
Some part of code:
import matplotlib.pyplot as plt
import scipy as sc
from matplotlib.animation import ArtistAnimation
...........
fig=plt.gcf()
ani=ArtistAnimation(fig,result,interval=10,repeat=False)
plt.show()
Even with TkAgg, matplotlib does not necessarily show the plot until you explicitly tell it to.
If you use pylab, you can explicitly cause it to show with something like this:
import pylab
pylab.plot([1,2,1,3])
pylab.show()
The call to show() will return when you close the window.
You can make it automatically show when you do a plot by writing
interactive: true
in your matplolibrc file. There is a system-wide config file in mpl-data/matplotlibrc in the installed packate. You have a personal config in ~/.matplotlib/matplotlibrc
Some systems seem to have interactive=true by default, others do not.
I found the answer here.
Finally!
(I have done manual install because it wanted the version 1.1)
I tried this :
sudo apt-get install python-pip
sudo pip install matplotlib
I seem to have a problem that is in parts very similar to the one mentioned here:
Python with eclipse import problem
But unfortunatly just in parts otherwise that would have solved mine as well.
I use Eclipse SDK, Version: 3.7.0 with PyDev 101.
Furthermore I have installed
numpy-1.6.1rc1-win32-superpack-python2.6.exe
and
matplotlib-1.0.1.win32-py2.6.exe
as noted here:
http://matplotlib.sourceforge.net/users/installing.html
I have rebuild all the packages and looks the site-packages are listed.
(by the way as you see it is an Python version installed with ArcGIS )
If I test a script for instance a very simple one like:
import numpy
import matplotlib
import pylab as pl
I get the following error in Eclipse:
import matplotlib
import pylab as pl
from matplotlib.pylab import *
ImportError: No module named pylab
Even though the interpreter for Pydev is pointing to the appropriate version of python and matplotlib is installed properly in there (site-packages) it does not work in Eclipse. In iPython it works perfect.
What still needs to be done to get matplotlib work in Eclipse?
Thanks a lot!
Werner
pylab is in matplotlibs namespace, so this should work:
import matplotlib.pylab as pylab
I found that turning off interactive move and then calling show worked.
import matplotlib.pyplot as plt
#...your code...
plt.ioff()
plt.show()
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.