本文介绍了如何在OS X上安装numpy和scipy?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Mac的新手,请多多包涵.

Hey guys I'm new to Mac so please bear with me.

此刻我正在使用雪豹10.6.4.

I'm using snow leopard 10.6.4 at the moment.

我想安装numpy和scipy,所以我从其官方网站下载了python2.6,numpy和scipy dmg文件.但是,我在导入numpy时遇到问题:

I want to install numpy and scipy, so I downloaded the python2.6,numpy and scipy dmg files from their official site. However, I'm having problem import numpy:

Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/numpy/core/multiarray.so: no matching architecture in universal wrapper

有人可以阐明这个问题吗?>

Can anyone shed some light to this problem?>

推荐答案

听起来好像您正在尝试从64位Python使用32位库一样.似乎有一个非正式的可用于Snow Leopard的64位Numpy .

Sounds as though you might be trying to use a 32-bit library from a 64-bit Python. Looks like there's an unofficial 64-bit Numpy available for Snow Leopard.

此处可用的Python 2.6 .dmg确实是32位的. (具体来说,这是一个既包含i386版本又包含ppc版本的通用二进制文件). 此处可用的常规numpy和scipy .dmg版本也是如此. (我怎么知道?请参见下文!)因此,如果您一起使用这些发行版,您会没事的.

The Python 2.6 .dmg available here is indeed 32-bit. (Specifically, it's a universal binary containing both i386 and ppc versions). The same is true of the regular numpy and scipy .dmg releases available here. (How do I know? See below!) So if you use those releases together you should be fine.

但是你还不行-所以我猜你是不是在使用从2.6 .dmg下载的Python版本.如果您正在运行可执行的python脚本,例如:

But you're not fine - so my guess is you're not using the version of Python from the 2.6 .dmg you downloaded. If you're running an executable python script, e.g.:

$ ./my-script.py

然后您可以尝试在命令行上显式指定要使用的Python.看起来MacPython .dmg安装到/usr/local/bin/python,所以请尝试:

then you could try specifying the Python you're using explicitly on the command line. Looks like the MacPython .dmg installs to /usr/local/bin/python, so try:

$ /usr/local/bin/python2.6 myscript.py

高兴吗?

我如何确定体系结构的那些.dmg文件的内容用于...

How I determined the architecture the contents of those .dmg files are built for...

  1. 安装.dmg(即双击它以打开一个卷)
  2. 使用gunzip和pax将包内容解压缩到本地目录,例如:

  1. Mount the .dmg (i.e. double-click it to open a volume)
  2. Use gunzip and pax to unpack the package contents to a local directory, e.g.:

$ mkdir tmp
$ cd tmp
$ gunzip -c /Volumes/Universal\ MacPython\ 2.6/MacPython.mpkg/Contents/Packages/PythonUnixTools-2.6.pkg/Contents/Archive.pax.gz | pax

  • 使用file检查软件包内容中的二进制文件

  • Use file to examine binary files in the package contents

    $ file Versions/2.6/bin/python
    Versions/2.6/bin/python: Mach-O universal binary with 2 architectures
    Versions/2.6/bin/python (for architecture ppc): Mach-O executable ppc
    Versions/2.6/bin/python (for architecture i386):    Mach-O executable i386
    

  • 这篇关于如何在OS X上安装numpy和scipy?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    08-04 07:47