简体   繁体   English

python 2.7没有安装matplotlib

[英]python 2.7 not installing matplotlib

Hi I'm trying to install matplotlib on my mac. 嗨,我正在尝试在我的mac上安装matplotlib。 I have lion OS X. 我有狮子OS X.

my python version is 2.7.1 ( this is what it says when I run it from terminal) 我的python版本是2.7.1 (这是我从终端运行它时所说的)

every time I install matplotlib, it promots this error 每次我安装matplotlib时,都会出现这个错误

matplotlib 1.1.0 cannot be installed on this disk. matplotlib requires System python 2.7 to install. 

I'm new to the python world and I need a tool to graph a few things... so a clear explanation is much appreciated. 我是蟒蛇世界的新手,我需要一个工具来绘制一些东西...所以非常感谢明确的解释。

Thanks! 谢谢!

You are installing a binary package which is going to expect a specific system python. 您正在安装一个二进制包,它将期望一个特定的系统python。 You are better off building from source. 你最好从源代码构建。

Just try installing it from pip: 只需尝试从pip安装它:

pip install numpy 
pip install matplotlib

If you do not yet have pip, you can install it like this: 如果您还没有pip,可以像这样安装:

wget "http://peak.telecommunity.com/dist/ez_setup.py"
python ez_setup.py
easy_install pip

If any of this fails, then follow @Nolen Royalty's guide that he mentioned in the comments 如果其中任何一项失败,请按照他在评论中提到的@Nolen Royalty指南进行操作

I've tried installing python in various different ways to get numpy, scipy, and matplotlib to all work together, and its a huge pain. 我已经尝试以各种不同的方式安装python来使numpy,scipy和matplotlib一起工作,这是一个巨大的痛苦。 Your exact version of python will dictate the version of numpy, scipy, and matlplotlib that will work for you. 你确切的python版本将决定适合你的numpy,scipy和matlplotlib的版本。

By far, the easiest solution I have found is to use the pre-built package Enthought. 到目前为止,我发现最简单的解决方案是使用预构建的包Enthought。 It takes care of all of those problems with one easy installer. 它通过一个简单的安装程序解决了所有这些问题。 You might get some additional software installed like mayavi (an interactive 3d plotting tool), but its not too much. 您可能会安装一些额外的软件,如mayavi(交互式3D绘图工具),但它不是太多。

If you are a student (or have ever been one since the dawn of email), you can download the entire Enthought package for free here . 如果您是学生(或者从电子邮件发布之日起就一直是学生),您可以在这里免费下载整个Enthought软件包。 Or you can visit the Enthought home at www.enthought.com . 或者您也可以访问Enthought回家www.enthought.com All you have to do is select the academic license and then insert a email that ends in .edu. 您所要做的就是选择学术许可,然后插入以.edu结尾的电子邮件。

I even think there are free trial versions which should solve the issue. 我甚至认为有免费试用版可以解决这个问题。 I've never tried any of the trial versions, but even if it is a limited time trial, you should be able to use the trial version, and then see exactly which versions of each package you need to install. 我从未尝试过任何试用版,但即使是限时试用,您也应该能够使用试用版,然后确切地查看需要安装的每个软件包的版本。 Its a little more roundabout, but it should work. 它稍微多了一点,但它应该工作。

I tried to install numpy, scipy, and matplolib on my Mac Book Pro running Lion many times and they all failed. 我尝试在运行Lion的Mac Book Pro上多次安装numpy,scipy和matplolib,但都失败了。 Nolen's recipe cam pretty close, but some of the matplotlib tests were failing in strange ways. Nolen的配方很接近,但是一些matplotlib测试以奇怪的方式失败了。 The method that worked for me can be found on the page Installing Python, virtualenv, NumPy, SciPy, matplotlib and IPython on Lion 可以在Lion安装Python,virtualenv,NumPy,SciPy,matplotlib和IPython的页面上找到适用于我的方法

Since you list you are new to Python, I recommend installing matplotlib with MacPorts. 由于您列出的是Python新手,我建议您使用MacPorts安装matplotlib。 First install macports http://www.macports.org/install.php then execute port install py27-matplotlib 首先安装macports http://www.macports.org/install.php然后执行port install py27-matplotlib

A couple of years ago there were some extra steps, but now it is this simple. 几年前还有一些额外的步骤,但现在就是这么简单。 You need to make sure you set your environment for the macports python, but that is provided in the documentation. 您需要确保为macports python设置环境,但这在文档中提供。

Have Fun! 玩得开心!

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

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