Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to install Matplotlib on Cygwin?

I'm trying to install Matplotlib 1.0.1 version on latest Cygwin. In the processing, there is a weird fork error cannot be solved. I googled similar questions and found that it might be solved by manually running gcc/g++ with matplotlib 0.98.5.2 : http://innuendopoly.org/arch/matplotlib-cygwin. But it doesn't work under 1.0.1 version. Does anybody encounter the same problem?

like image 339
freezy Avatar asked Mar 01 '11 07:03

freezy


3 Answers

Here are instructions for how to install matplotlib 1.1.0 on Cygwin

http://berlinbrowndev.blogspot.com/2012/01/python-matplotlib-plotting-setup-for.html

Python matplotlib plotting setup for cygwin

Matplotlib is a popular python library for generating plot graphics. It works with cygwin win32 but some non-intuitive steps are required.

Install cygwin:

CYGWIN_NT-5.1 1.7.9(0.237/5/3) 2011-03-29 10:10 i686 Cygwin

I am using cygwin with setup 2.7.3

Install python through cygwin:

This document describes installing python and matplot with cygwin. For most windows users and cygwin users, normally you would use the external python executable. I tend to prefer all of my script oriented applications running through cygwin including python.

Python 2.6.5 (r265:79063, Jun 12 2010, 17:07:01)
[GCC 4.3.4 20090804 (release) 1] on cygwin

In the cygwin setup.exe installer, install:

  • The freetype libs, python-gtk, python-tk, libpng
  • gcc

Download matplotlib from sourceforge:

I am using the latest version matplotlib-1.1.0 as of 1/2012.

Download and extract the matplotlib tarball

Issues with standard python install and cygwin:

The typical 'python setup.py install' will not work with cygwin. You need to modify a configuration file and run some other additional commands.

In the root directory of the expanded matplotlib directory, copy the setup.cfg.template configuration file to setup.cfg. Edit setup.cfg.

Around line 70 in the file is a commented line, uncomment the line such that you have:

tkagg = False

Run install and watch it fail

Try running 'python setup.py install'

It should fail with an error like the following:

2 [main] python 2796 C:\cygwin\bin\python.exe: *** fatal error - unable to remap C:\cygwin\bin\cyggfortran-3.dll to same address as parent: 0x18660000 != 0x69780000
Stack trace:

Run the rebase command OUTSIDE OF THE TYPICAL CYGWIN ENV

Exit cygwin and close all cygwin instances including the one you are working with. You won't be using the typical cygwin prompt for the next command.

In windows explorer, open the cmd.exe or windows command

You will need to run rebaseall. First, shut down any long running processes like sshd, close all Cygwin prompts and so on.

Type the following commands:

cd \cygwin\bin
ash
PATH=. rebaseall -v

...

And you should get several lines of output.

Run install and watch it succeed

Try running 'python setup.py install' command again in the matplotlib directory

Running Example Program:

# python
Python 2.6.5 (r265:79063, Jun 12 2010, 17:07:01)
[GCC 4.3.4 20090804 (release) 1] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
import matplotlib.pyplot as pyplot
pyplot.pie([1,2,3])
pyplot.show()
pyplot.savefig('f.png')
pyplot.savefig('x.eps')
like image 57
Brion Finlay Avatar answered Nov 07 '22 07:11

Brion Finlay


These steps taken from www.scivision.co worked for me:

  1. Run Cygwin setup: (For some reason the original command posted in the source link did not work for me)
  2. install packages: (most of these you may already have)

    • pkg-config
    • ghostscript
    • libfreetype-devel
    • libpng-devel
    • libgtk2.0-devel
    • gcc-g++
    • git
    • openbox
    • python3-numpy
    • python3-pyqt5
    • python3-devel
  3. Then from Cygwin Terminal:

easy_install-3.6 pip pip install --upgrade six pip install matplotlib

  1. Then tested from python console:

import matplotlib matplotlib.__version__

like image 6
Felix Avatar answered Nov 07 '22 06:11

Felix


Installation worked for me as described by Felix above. But to use matplotlib you need to start the Xserver from Cygwin first:

startxwin

and then start your script.

like image 1
Felix Kastner Avatar answered Nov 07 '22 06:11

Felix Kastner