zoukankan      html  css  js  c++  java
  • mac安装numpy引发的一系列问题

    在安装numpy和matplotlib过程中,直接提示“numpy requires System Python 2.7 to install”,但是mac电脑自带的Python本身是2.7,在stackoverflow上找到一篇文章

    http://stackoverflow.com/questions/20058733/numpy-requires-system-python-2-7-to-install

    和我遇到的问题是一样的。意思是numpy和matplotlib模块需要32位的Python,但是mac自带的是64位的,需要我们重新下载32位Python进行安装。

    32位安装地址:https://www.python.org/download/releases/2.7.6/

    我重新下载并安装后,重启电脑,numpy和matplotlib安装成功。

    mac安装matplotlib的步骤:

    http://www.tuicool.com/articles/2Mj6Jb

    首先安装numpy,去 sourceforge 下载了numpy-1.7.1-py2.7-python.org-macosx10.6.dmg,安装是傻瓜式的,安装完在python命令行输入import numpy测试没有问题。

    然后安装matplotlib,去 github 下载了matplotlib-1.2.1-py2.7-python.org-macosx10.6.dmg,也是傻瓜式安装,安装完在python命令行输入import matplotlib,提示not load X11的一个东西,去下载 XQuartz 并安装,再次输入import matplotlib就没有问题了。

    然后写了下面这段简单的代码测试:

    1. import  matplotlib.pyplot as plt  
    2.   
    3. plt.plot([1,2,3])  
    4. plt.ylabel('some numbers')  
    5. plt.show()  

    然后问题来了,报错: STACK: Stack after current is in use 。折腾了一整天,把官方的faq全看了,看到 这篇 讲到在普通python命令行下使用matplotlib的限制,试了下也不行。回想以前的经验,在pydev设置里配置环境变量什么的也无效。最后无意间在matplotlib的github页面看到这一句话:

    matplotlib-1.2.0-py2.7-python.org-macosx10.6.dmg — Binary installer for python.org's 64-bit python 2.7 and MacOS X 10.6 or later

    会不会是32位和64位python的问题,因为前几日为了使用MySQLdb安装了python2.7的32位版本,而当前系统默认使用这个版本。于是删除了之前安装的64位版本并下载和安装了这个版本的matplotlib:

    matplotlib-1.2.0-py2.7-python.org-macosx10.3.dmg — Binary installer for python.org's 32-bit python 2.7 and MacOS X 10.3.9 or later

    再测试那段代码,就看到图表了:


    点击看大图

    这个问题浪费了一天的时间,唯一查到的 stackoverflow 答案也没有人能解答。但是令人奇怪的是安装的64位numpy又完全没有问题= =。

  • 相关阅读:
    [HDU3555]Bomb
    [POJ3096]Surprising Strings
    [POJ1068]Parencodings
    [POJ3295]Tautology
    [POJ2586]Y2K Accounting Bug
    [POJ2109]Power of Cryptography
    [POJ1328]Radar Installation
    Binary search tree system and method
    ES6详解八:模块(Module)!--各种导入导出方法
    java在cmd下编译和执行引用jar的类
  • 原文地址:https://www.cnblogs.com/ppsunlight/p/3755661.html
Copyright © 2011-2022 走看看