简体   繁体   English

如何在Cygwin上安装Matplotlib?

[英]how to install Matplotlib on Cygwin?

I'm trying to install Matplotlib 1.0.1 version on latest Cygwin. 我正在尝试在最新的Cygwin上安装Matplotlib 1.0.1版本。 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 . 我搜索了类似的问题,发现它可以通过使用matplotlib 0.98.5.2手动运行gcc / g ++来解决: http ://innuendopoly.org/arch/matplotlib-cygwin。 But it doesn't work under 1.0.1 version. 但它在1.0.1版本下不起作用。 Does anybody encounter the same problem? 有人遇到同样的问题吗?

Here are instructions for how to install matplotlib 1.1.0 on Cygwin 以下是如何在Cygwin上安装matplotlib 1.1.0的说明

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

Python matplotlib plotting setup for cygwin 用于cygwin的Python matplotlib绘图设置

Matplotlib is a popular python library for generating plot graphics. Matplotlib是一个流行的python库,用于生成绘图图形。 It works with cygwin win32 but some non-intuitive steps are required. 它适用于cygwin win32,但需要一些非直观的步骤。

Install cygwin: 安装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 我正在使用cygwin和setup 2.7.3

Install python through cygwin: 通过cygwin安装python:

This document describes installing python and matplot with cygwin. 本文档描述了使用cygwin安装python和matplot。 For most windows users and cygwin users, normally you would use the external python executable. 对于大多数Windows用户和cygwin用户,通常你会使用外部python可执行文件。 I tend to prefer all of my script oriented applications running through cygwin including python. 我倾向于选择通过cygwin运行的所有面向脚本的应用程序,包括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: 在cygwin setup.exe安装程序中,安装:

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

Download matplotlib from sourceforge: 从sourceforge下载matplotlib:

I am using the latest version matplotlib-1.1.0 as of 1/2012. 我使用最新版本的matplotlib-1.1.0截至2012年1月。

Download and extract the matplotlib tarball 下载并解压缩matplotlib tarball

Issues with standard python install and cygwin: 标准python安装和cygwin的问题:

The typical 'python setup.py install' will not work with cygwin. 典型的'python setup.py install'不适用于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. 在展开的matplotlib目录的根目录中,将setup.cfg.template配置文件复制到setup.cfg。 Edit setup.cfg. 编辑setup.cfg。

Around line 70 in the file is a commented line, uncomment the line such that you have: 文件中的第70行是注释行,取消注释该行,使您具有:

tkagg = False

Run install and watch it fail 运行安装并观察它失败

Try running 'python setup.py install' 尝试运行'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 在典型的CYGWIN ENV外面运行rebase命令

Exit cygwin and close all cygwin instances including the one you are working with. 退出cygwin并关闭所有cygwin实例,包括您正在使用的实例。 You won't be using the typical cygwin prompt for the next command. 您不会将典型的cygwin提示用于下一个命令。

In windows explorer, open the cmd.exe or windows command 在Windows资源管理器中,打开cmd.exe或Windows命令

You will need to run rebaseall. 您将需要运行rebaseall。 First, shut down any long running processes like sshd, close all Cygwin prompts and so on. 首先,关闭任何长时间运行的进程,如sshd,关闭所有Cygwin提示等等。

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 尝试在matplotlib目录中再次运行'python setup.py install'命令

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')

These steps taken from www.scivision.co worked for me: www.scivision.co采取的这些步骤对我有用

  1. Run Cygwin setup: (For some reason the original command posted in the source link did not work for me) 运行Cygwin设置:(由于某种原因,源链接中发布的原始命令对我不起作用)
  2. install packages: (most of these you may already have) 安装包:(你可能已经拥有大部分)

    • pkg-config pkg配置
    • ghostscript 的ghostscript
    • libfreetype-devel libfreetype建立-devel的
    • libpng-devel 的libpng-devel的
    • libgtk2.0-devel libgtk2.0-devel的
    • gcc-g++ GCC-克++
    • git 混帐
    • openbox 开箱
    • python3-numpy python3-numpy的
    • python3-pyqt5 python3-pyqt5
    • python3-devel python3-devel的
  3. Then from Cygwin Terminal: 然后从Cygwin Terminal:

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

  1. Then tested from python console: 然后从python控制台测试:

import matplotlib matplotlib.__version__

Installation worked for me as described by Felix above. 如上面Felix所述,安装对我有用。 But to use matplotlib you need to start the Xserver from Cygwin first: 但要使用matplotlib,您需要首先从Cygwin启动Xserver:

startxwin

and then start your script. 然后启动你的脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM