I'm new to matplotlib. My environment is WinXP, PythonWin 2.6.2, NumPy 1.3.0, matplotlib 0.98.5.3.
>>> import matplotlib.pylab as pylab
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "D:\Python26\lib\site-packages\matplotlib\pylab.py", line 253, in <module>
from matplotlib.pyplot import *
File "D:\Python26\lib\site-packages\matplotlib\pyplot.py", line 75, in <module>
new_figure_manager, draw_if_interactive, show = pylab_setup()
File "D:\Python26\lib\site-packages\matplotlib\backends\__init__.py", line 25, in pylab_setup
globals(),locals(),[backend_name])
File "D:\Python26\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 8, in <module>
import tkagg # Paint image to Tk photo blitter extension
File "D:\Python26\lib\site-packages\matplotlib\backends\tkagg.py", line 1, in <module>
import _tkagg
ImportError: DLL load failed: cannot find the module
I searched the web and it's said because lack of msvcp71.dll, but there is already one in my C:\windows\system32\
anyone can help?
Thanks.
try this, before using any other module
import matplotlib
matplotlib.use('Agg')
import matplotlib.pylab as pylab
see http://www.mail-archive.com/matplotlib-users#lists.sourceforge.net/msg05372.html for more details and other ways
matplotlib can use different backends for rendering, agg is pure draw with no UI, so you can only save images e.g.
plt.savefig("plt.png")
read http://matplotlib.sourceforge.net/faq/installing_faq.html#what-is-a-backend for more details, e.g. you can output to ps, pdf, wxagg, tkagg etc, so if you have wxpython installed use this
matplotlib.use('wxagg')
also i think tkagg backend should have been work, as tkinter(http://wiki.python.org/moin/TkInter) is default gui with python, did you install python from python.org?
I had the same problem installing activestat python 2.6 and pylab. After installing the sourceforge python 2.6.2 however it worked fine
I actually found the answer and the graphs are running great on my computer. If you are getting a DLL error like this, try downloading msvcp71.dll and msvcr71.dll in your computer and then copy paste these two in your System32 folder:
C:\Windows\System32
and also copy-paste these two dll's in SysWOW64 folder if you are working on 64bit operating System
C:\Windows\SysWOW64
Now try running your code file in Python and it will load the graph in couple of seconds. Here is the link which says how to copy-paste dll's to both folder, this might help
http://www.youtube.com/watch?v=xmvRF7koJ5E
Cheers...
I had this issue using iPython notebooks using Python 2.7. Apparently the latest Seaborn update does not play well with my local configuration settings, so I did "conda/pip install seaborn=0.5.1". It downgraded the necessary packages automatically, and my problem went away.
Related
I'm attempting to figure out the mechanics of running Python scripts in Power BI for Reasons and I've hit a snag. I was running through the steps in this somewhat basic tutorial and I came to the section in which I am supposed to paste the script into they Python Script screen, which is Step 3 of the 'Run the Script and Import Data' section.
When I followed the steps, which are essentially to paste the example script into the window and hit Okay, I got this 'helpful' error:
`
Details: "ADO.NET: Python script error.
<pi>Traceback (most recent call last):
File "C:\Users\my.username\PythonScriptWrapper_aca634c7-30c3-4bf4-881b-d1e47bb0a919\PythonScriptWrapper.PY", line 2, in <module>
import os, pandas, matplotlib
File "C:\Users\my.username\Anaconda3\lib\site-packages\matplotlib\__init__.py", line 109, in <module>
from . import _api, _version, cbook, docstring, rcsetup
File "C:\Users\my.username\Anaconda3\lib\site-packages\matplotlib\rcsetup.py", line 27, in <module>
from matplotlib.colors import Colormap, is_color_like
File "C:\Users\my.username\Anaconda3\lib\site-packages\matplotlib\colors.py", line 51, in <module>
from PIL import Image
File "C:\Users\my.username\Anaconda3\lib\site-packages\PIL\Image.py", line 89, in <module>
from . import _imaging as core
ImportError: DLL load failed while importing _imaging: The specified module could not be found.
</pi>"
`
I have verified that the matplotlib and pandas packages were installed via pip list, os doesn't show up, which surprised me but I know it's part of the standard library so I'm not stressing about it unless someone thinks I should. Is anyone an expert in this? Is there a better way? Am I doomed to scream into the Power BI void for all eternity?
The somewhat basic tutorial is based on using standard python from python.org. However, you are using the Anaconda distribution, which basically requires the environment to be activated before any modules - especially pandas' C-library - can be accessed.
You can achieve that in the cmd shell by running
conda activate
C:\Users\my.username\AppData\Local\Microsoft\WindowsApps\PBIDesktopStore.exe
which assumes that you are using the Power BI Desktop version from the Microsoft store.
Hi everybody since im new to python 3 I tried to install Matplotlib in python but after installment there are multiple occuring errors
after importing matplotlip:
import matplotlib.pyplot as plt
and run the program I get:
Traceback (most recent call last):
File "C:/Users/Panos/Desktop/Python/for_loop/for_loop.py", line 34, in <module>
import matplotlib.pyplot as plt
File "E:\Program Files\Python\lib\site-packages\matplotlib\__init__.py", line 174, in <module>
_check_versions()
File "E:\Program Files\Python\lib\site-packages\matplotlib\__init__.py", line 159, in _check_versions
from . import ft2font
ImportError: DLL load failed while importing ft2font: The specified module could not be found.
have anyone faced the same problem with matplotlib package using PyCharm as well?
other packages as Numpy or e.g. Pandas are working fine..
#Pan Pan try to install matplotlib 3.0.3 it fixed ft2font problem for some cases
pip uninstall matplotlib
pip install matplotlib==3.0.3
well I just tried a new install of an oldest version and it finally worked!
I didn't use pip install - I just went to PyCharms interpreter and selected matplotib package (using "+" button in the bottom left corner).
Then I checked to specify the version of the matlibplot package and after several efforts of installing-uninstalling matplotlib version the --> 3.1.3 worked for me without errors
from matplotlib import ft2font
import matplotlib.pyplot as plt
Hope that helps people with the same issue
#Amin Kh thank you for your initial suggestion! :)))
I use Pydev and try to load numpy in my script. I installed Anaconda to be able to use it, following the Anaconda user guide concerning how to set it up as interpreter in Pydev.
I have tried installing Anaconda both with and without adding it to PATH (the recommended version is without). In both cases numpy shows up as an installed package in Pydev:
However, when I run my script I receive the following error:
File "Z:\Path\To\My\file.py", line 2, in <module>
import numpy as np
File "C:\Users\(username)\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "C:\Users\(username)\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.
I also noticed that in the manual from anaconda, in the shown picture a lot more library folders are added than what I am presented with. I couldn't find a list of those, though. Running numpy from the Anaconda prompt works fine.
Any ideas would be appreciated!
I'm trying to write a program that plots a graph, which made me look into
Matplotlib.
I found a tutorial that started out with this little program, that worked fine:
from pylab import *
def main():
X = np.linspace(-np.pi, np.pi, 256, endpoint=True)
C,S = np.cos(X), np.sin(X)
plot(X,C)
plot(X,S)
show()
if __name__ == '__main__':
main()
Then I tried to run it on another computer, where it did not work at all. I tried to download Pylab and Matplotlib. When I had installed Matplotlib it demanded something called dateutil, when I got dateutil it demanded something called six. I downloaded six, but it didn't work properly.
It doesn't feel like I'm on the right track. What should I do to get a proper installation?
EDIT:
I'm using Python 2.7 on Windows 7.
The error I get is
Traceback (most recent call last):
File "C:\Users\Python\mscript\listdb2.py", line 19, in <module>
from pylab import *
File "C:\Python27\lib\site-packages\pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "C:\Python27\lib\site-packages\matplotlib\pylab.py", line 226, in <module>
import matplotlib.finance
File "C:\Python27\lib\site-packages\matplotlib\finance.py", line 21, in <module>
from matplotlib.dates import date2num
File "C:\Python27\lib\site-packages\matplotlib\dates.py", line 119, in <module>
from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY,
File "C:\Python27\lib\site-packages\dateutil\rrule.py", line 18, in <module>
from six import advance_iterator, integer_types
ImportError: No module named six
The file six.py is located in C:\python27\Lib\site-packages\six\six.py
The six directory also contains a file called test_six.py. If I try to run this program I also get an error:
Traceback (most recent call last):
File "test_six.py", line 5, in <module>
import.py
ImportError: No module named py
If Anaconda installed and it is already in your environment path, you can get it simply using
conda install matplotlib
in command line and then call in Python with
from pylab import *
This work for me fine as "pip install" and "easy_install" both on Win and Linux caused a lot of issues
Installing packages on *nix is easy using pip. Pip allows you to easily install packages from the Python Package Index (PyPI) with a simple pip install matplotlib. This should install all dependencies, but if it does not then you can install them manually (for instance pip install python-dateutil).
Using pip with Windows is possible though slightly more difficult for packages that require compilers and such. However, installing Python programs on Windows is simple if you use these Windows binaries provided by Christoph Gohlke.
The particular ones for matplotlib can be found here. Note that you can also find similar binaries for python-dateutil, six, etc if necessary.
*As an aside: I would strongly suggest you look into using the full matplotlib.pyplot API rather than pylab. It's much more powerful and useful, but this is just some aside advice :) *
I have a very similar question to this one: matplotlib does not show my drawings although I call pyplot.show()
I am using:
Ubuntu 12.04;
Python 3.4.1;
Pycharm 3.4.1
So, I run the following code in pyCharm using 3.4.1 interpreter and plot doesn't appear:
import matplotlib.pyplot as p
p.plot(range(20), range(20))
p.show()
Then I thought it could be something with pycharm, therefore I have tried the same in the terminal. However, plot didn't appear too.
However, since Ubuntu is with built-in Python 2.7, I have tried the same on terminal, then on pycharm and plot did appear.
I have found out that backend in matplotlibrc file should be changed. I googled, that qt4agg backend should be used. After changing it and trying to import matplotlib.pyplot I get the following
import matplotlib.pyplot as p
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/matplotlib/pyplot.py", line 98, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/__init__.py", line 28, in pylab_setup
globals(),locals(),[backend_name],0)
File "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_qt4agg.py", line 13, in <module>
from .backend_qt4 import QtCore, QtGui, FigureManagerQT, FigureCanvasQT,\
File "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_qt4.py", line 25, in <module>
from .qt4_compat import QtCore, QtGui, _getSaveFileName, __version__
File "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/qt4_compat.py", line 36, in <module>
import sip
ImportError: No module named 'sip'
Therefore, I installed sip using
sudo apt-get install python3-sip
and the same error appears.
I am trying to find out whats wrong with SIP. However, I am kinda confused, any help would be appreciated.
Thanks
Alright, so after a lot of effort, I finally managed to do it.
Firstly, I had probably, three or four different python versions in my computer: 2.7 as ubuntu default, 3.2, 3.4.0 and 3.4.1. Each of them had different versions of matplotlib (majority 1.3.1). So, firstly I cleaned up useless python versions (3.2, 3.4).
Secondly, I removed all available matplotlib directories. I used matplotlib documentation to determine which folders should be removed to fully remove it. (http://matplotlib.org/contents.html)
After that, I cloned newest matplotlib version from git (http://matplotlib.org/faq/installing_faq.html#install-from-git) and installed it. And this point matplotlib version is 1.4. Then I tried to reproduce my first example again and it worked. No backend was changed.
Thus, clean removal and newest version should do the trick.