Install matplotlib in Windows

I presume that you have already installed python in your PC and added it to system path. And now you want to install one of the best plotting library matplotlib. It is pretty straightforward in a linux-based OS with a package manager. But in Windows –

1) Install distribute: It helps in installing python packages easily. Download file, open windows command prompt or powershell and using ‘cd’ command change to the folder containing the downloaded file, then perform the following command to install distribute –

python distribute_setup.py

2) Add easy-install to system PATH: We have to add the Scripts directory to the system path. If you have python 3.3, the path to the Scripts directory is C:\Python33\Scripts\ The method of adding a directory to system path has already shown in the previous tutorial.

3) Install matplotlib: There are certain dependencies needed to be installed for matplotlib working correctly. But these are no more our concern. The distribute package will check for dependencies and install it automatically. We just have to run this command –

easy_install matplotlib

Voila! We have successfully installed matplotlib.

4) Test it: Now start python interpreter and run the following commands to test the plotting library –

>> import pylab
>> x = [i/10 for i in range(0, 100)]
>> y = [i*i for i in x]
>> pylab.plot(x, y)
[...]
>> pylab.show()

Output of the last command is the following plot – figure 1

Advertisements

4 thoughts on “Install matplotlib in Windows

  1. For installing matplotlib, I have done same as u instructed above but I end up with
    import error: DLL load failed: %1 is not a valid win32 application .
    Let me know how to proceed

  2. This paragraph gives clear idea in favor of the new viewers
    of blogging, that actually how to do blogging.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s