gpt4 book ai didi

numpy - 在 OS X 10.7.4 上为 Python 3.2.3 安装 NumPy

转载 作者:行者123 更新时间:2023-12-04 13:33:47 27 4
gpt4 key购买 nike

几个月来,我一直在尝试为 Python 3 安装 numpy,但尽管进行了大量的谷歌搜索,甚至发布到 numpy 邮件列表,但我仍然没有接近解决方案。

我已经设法通过 MacPorts 安装了它,但不幸的是似乎没有适用于 Python 3 的 MatPlotLib 端口,这是我尝试安装 numpy 的主要原因……所以我有点卡住了……

尝试从 setup.py 文件构建时,我不断收到相同的错误。我在下面包含了终端输出。

谢谢你的尽心帮助,

亚当。

这是终端输出:

lipo: can't figure out the architecture type of: /var/folders/zj/7xymy_2n3s71ws30v3v_qnlw0000gn/T//ccbRr0Hj.out
failure.
removing: _configtest.c _configtest.o
Running from numpy source directory.Traceback (most recent call last):
File "setup.py", line 214, in <module>
setup_package()
File "setup.py", line 207, in setup_package
configuration=configuration )
File "/Users/adammcnicol/Downloads/numpy-1.6.2rc1/build/py3k/numpy/distutils/core.py", line 186, in setup
return old_setup(**new_attr)
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/distutils/core.py", line 148, in setup
dist.run_commands()
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/distutils/dist.py", line 917, in run_commands
self.run_command(cmd)
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/distutils/dist.py", line 936, in run_command
cmd_obj.run()
File "/Users/adammcnicol/Downloads/numpy-1.6.2rc1/build/py3k/numpy/distutils/command/build.py", line 37, in run
old_build.run(self)
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/distutils/command/build.py", line 126, in run
self.run_command(cmd_name)
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/distutils/dist.py", line 936, in run_command
cmd_obj.run()
File "/Users/adammcnicol/Downloads/numpy-1.6.2rc1/build/py3k/numpy/distutils/command/build_src.py", line 152, in run
self.build_sources()
File "/Users/adammcnicol/Downloads/numpy-1.6.2rc1/build/py3k/numpy/distutils/command/build_src.py", line 169, in build_sources
self.build_extension_sources(ext)
File "/Users/adammcnicol/Downloads/numpy-1.6.2rc1/build/py3k/numpy/distutils/command/build_src.py", line 328, in build_extension_sources
sources = self.generate_sources(sources, ext)
File "/Users/adammcnicol/Downloads/numpy-1.6.2rc1/build/py3k/numpy/distutils/command/build_src.py", line 385, in generate_sources
source = func(extension, build_dir)
File "numpy/core/setup.py", line 410, in generate_config_h
moredefs, ignored = cocache.check_types(config_cmd, ext, build_dir)
File "numpy/core/setup.py", line 41, in check_types
out = check_types(*a, **kw)
File "numpy/core/setup.py", line 271, in check_types
"Cannot compile 'Python.h'. Perhaps you need to "\
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.

最佳答案

好吧,我终于设法得到 NumPy 安装。不确定这是最好的方法,但它似乎有效!

首先我需要安装分发 :

  • curl http://python-distribute.org/distribute_setup.py | python3

  • 然后我安装了 :
  • curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python3

  • 之后我必须得到 进入我的系统路径(可能还有更好的方法):
  • 打开终端
  • 键入以下内容(单行):
  • sudo ln -s /Library/Frameworks/Python.framework/Versions/3.2/bin/pip /usr/local/bin

  • 分发安装我然后安装 Nose , NumPy 需要测试什么的:
  • 再次,在 终端 键入以下内容:
  • pip install nose

  • 现在我需要确保我拥有最新版本的 Xcode :
  • 来自 应用商店 安装最新版本的 Xcode
  • 如果您还有 /Developer文件夹然后重命名Developer-old (不确定这是否会在以后给我带来问题)
  • 打开终端 并创建一个指向 Xcode 的 AppStore 版本的符号链接(symbolic link)(单行):
  • sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer /Developer

  • 完成所有这些后,安装 NumPy :
  • 下载 NumPy 来源:http://sourceforge.net/projects/numpy/files/NumPy/1.6.2rc1/
  • 解压文件
  • 打开终端 再次:
  • cd进入通过取消归档文件创建的目录,例如
  • cd /Users/username/Downloads/numpy-1.6.2rc1
  • 输入 终端 以下更改用于构建 的编译器NumPy :
  • export CC=clang
  • export CXX=clang
  • export FFLAGS=-ff2c
  • export LDSHARED='clang -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -g' (这是单行)
  • python3 setup.py build (这可能需要一段时间)
  • python3 setup.py install

  • 好的,假设没有错误 NumPy 应该安装。是时候测试一下了:
  • 打开空闲
  • Python 外壳 类型:
  • import numpy
  • numpy.test('full')
  • 这将测试 NumPy 我收到的最终结果 Python 3.2.3 曾是:
  • <nose.result.TextTestResult run=3192 errors=0 failures=1>

  • 所以 NumPy 安装通过了除了一项测试之外的所有测试,这似乎相当不错。我还没有机会查看是否可以正常工作,因为我仍在努力获得 matplotlib 安装...

    希望这些说明对某人有用!

    亚当。

    关于numpy - 在 OS X 10.7.4 上为 Python 3.2.3 安装 NumPy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10557857/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com