简体   繁体   English

使用 Python 2.7 安装 numpy Lion?

[英]Installing numpy Lion with Python 2.7?

I am working on a OS X 10.7 with Python 2.7 from python.org and XCode 4.2.我正在使用 Python 2.7 来自 python.org 和 XCode 4.2 的 OS X 10.7。

  1. Following these instructions , I tried changing the CC , CXX , and FFLAGS variables and install with sudo pip install numpy .按照这些说明,我尝试更改CCCXXFFLAGS变量并使用sudo pip install numpy However, the installation still looks for gcc-4.2 .但是,安装仍会查找gcc-4.2
  2. I tried installing gcc-4.2 through MacPorts but get that Error: gcc42 does not build on Snow Leopard or later.我尝试通过 MacPorts 安装gcc-4.2但出现Error: gcc42 does not build on Snow Leopard or later.
  3. When I install numpy from the precompiled binary on sourceforge, I get the following error:当我从 sourceforge 上的预编译二进制文件安装 numpy 时,出现以下错误:

    import numpy进口 numpy

    Traceback (most recent call last):回溯(最后一次通话):

    File "", line 1, in文件“”,第 1 行,位于

    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/ init .py", line 137, in文件“ /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/init .py”,第 137 行,在

    import add_newdocs

    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/add_newdocs.py", line 9, in文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/add_newdocs.py”,第 9 行,在

    from numpy.lib import add_newdoc

    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/ init .py", line 4, in文件“ /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/init .py”,第 4 行,在

    from type_check import *

    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/type_check.py", line 8, in文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/type_check.py”,第 8 行,在

    import numpy.core.numeric as _nx

    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/ init .py", line 5, in文件“ /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/init .py”,第 5 行,在

    import multiarray

    ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/multiarray.so, 2): no suitable image found. ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/multiarray.so, 2): 找不到合适的图像。 Did find: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/multiarray.so: no matching architecture in universal wrapper确实找到了:/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/multiarray.so:通用包装器中没有匹配的架构

Any help?有什么帮助吗?

If I recall correctly the precompiled binary on source forge is 32-bit.如果我没记错的话,source forge 上的预编译二进制文件是 32 位的。 It took me ages to get Numpy, Scipy, and Matplotlib set up on my macbook, it's definitely much harder than it should be.我花了很长时间才在我的 macbook 上设置 Numpy、Scipy 和 Matplotlib,这肯定比它应该的要难得多。

I believe that your best option is the Scipy superpack .我相信您最好的选择是Scipy 超级包 Before using the superpack you need to update to Xcode 4.3.2在使用超级包之前你需要更新到 Xcode 4.3.2

So I just installed python 2.7.2 from python.org, grabbed the superpack, and now have numpy working on my machine.所以我刚刚从 python.org 安装了 python 2.7.2,获取了超级包,现在 numpy 在我的机器上运行。 After installing python 2.7.2, I did sudo pip uninstall numpy , which didn't remove enough.安装 python 2.7.2 后,我做了sudo pip uninstall numpy ,但没有删除足够。 So I cd'd into /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ and moved both the numpy directory and the numpy egg to "old" versions of themselves.所以我进入/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/并将 numpy 目录和 numpy egg 移动到它们自己的“旧”版本。 Then I ran sh install_superpack.sh and answered no to the "are you installing from a repository cloned to this machine(pretty important lol, hit yes without thinking the first time).然后我运行sh install_superpack.sh并对“你是从克隆到这台机器的存储库安装吗(非常重要,哈哈,第一次不假思索地点击是)”回答

However, now I'm able to do this:但是,现在我可以这样做了:

$ python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import scipy
>>> import matplotlib

With no problems:)没问题:)

SuperPack worked for me (thanks, @Nolen) on OS X 10.8 (Mountain Lion) w/ XCode 4.5.1 installed. SuperPack 在安装了 XCode 4.5.1 的 OS X 10.8 (Mountain Lion) 上为我工作(谢谢,@Nolen)。

Numpy worked for me using pip install numpy after step #1 below. Numpy 在下面的第 1 步之后使用pip install numpy为我工作。 But scipy would not install using pip. SuperPack fixed this.但是 scipy不会使用 pip 安装。SuperPack 修复了这个问题。

The only thing I did differently was to use HomeBrew to install Python as step #1, rather than download it manually.我唯一不同的是使用 HomeBrew 安装 Python 作为第 1 步,而不是手动下载。

  1. Install Python (separate from version that comes with OS X 10.8)安装 Python(与 OS X 10.8 附带的版本分开)

    • brew install python --framework --universal
    • pushd /System/Library/Frameworks/Python.framework/Versions
    • sudo rm Current
    • sudo ln -s /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/Current
    • popd
  2. Install SuperPack:安装超级包:

    • curl -o install_superpack.sh https://raw.github.com/fonnesbeck/ScipySuperpack/master/install_superpack.sh
    • sh install_superpack.sh
    • (type your admin password several times during the installation...) (在安装过程中多次输入您的管理员密码...)

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

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