我想在 osx lion 中使用 matplotlib [英] I want to use matplotlib in osx lion

查看:33
本文介绍了我想在 osx lion 中使用 matplotlib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 macports 安装了 matplotlib,python 版本是 2.7.1.

I installed matplotlib from macports, and version of python is 2.7.1.

$ sudo port install py27-matplotlib py27-matplotlib-basemap

我在下面写了一个示例程序.

I wrote a sample program below.

#!/usr/bin/python
# -*- coding: utf-8 -*-

from pylab import *
plot([1,2,3])
show()

但这不能正常工作,错误日志没有名为 pylab 的模块".

But this didn't work correctly with error log "no module named pylab".

我尝试了easy_install.

And I tried easy_install.

$ sudo easy_install matplotlib

在这种情况下,我的程序运行正常,没有错误.

In this case, my program worked correctly with no errors.

这两种情况(macports和easy_install)有什么区别?

What is the difference between these two cases(macports and easy_install)?

我认为matplotlib的版本在两种情况下是相同的.

I think the version of matplotlib is same in two cases.

在Macports中,我是否需要重新定义包含路径?

In case of macports, do I have to redefine include path?

您能帮我吗?

推荐答案

为确保兼容环境,MacPorts Python 包会自动安装 MacPorts Python.默认情况下,您可以通过/opt/local/bin/python2.7 调用它.在那里你会发现安装了 MacPorts matplotlib 等./usr/bin/python 将调用 Apple 提供的系统 Python 2.7.1,当您运行 sudo easy_install 时,您使用的是 Apple 提供的 easy_install与系统Python关联的命令.这意味着您现在安装了两个 Python 2.7 实例,每个实例都有一个单独的 matplotlib 版本.这没什么不对,但是您可能想要坚持一个或另一个.您可以通过确保您的 SHELL 路径在 /usr/bin 之前具有 /opt/local/bin 并使用 MacPorts port 使 MacPorts Python 2.7 成为您的默认值选择python python27 命令.

To ensure a compatible environment, MacPorts Python packages automatically install a MacPorts Python. By default, you can invoke it via /opt/local/bin/python2.7. And that's where you will find the MacPorts installed matplotlib et al. /usr/bin/python will invoke the Apple-supplied system Python 2.7.1 and, when you ran sudo easy_install you were using the Apple-supplied easy_install command associated with the system Python. That means you now have two Python 2.7 instances installed, each with a separate version of matplotlib. There's nothing wrong with that but you probably want to stick with one or the other. You can make the MacPorts Python 2.7 be your default by ensuring your SHELL path has /opt/local/bin before /usr/bin and by using the MacPorts port select python python27 command.

这篇关于我想在 osx lion 中使用 matplotlib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆