【问题标题】:Numpy Install/Build Mac OsxNumpy 安装/构建 Mac Osx
【发布时间】:2013-01-25 20:25:15
【问题描述】:

所以我按照这个网站上的指示http://www.scipy.org/Installing_SciPy/Mac_OS_X,下载了 Xcode 和 Fortran Gcc,然后从终端运行以下命令:

Megans-MacBook-Pro:~ MeganRCunninghan$ export CC=clang
Megans-MacBook-Pro:~ MeganRCunninghan$ export CXX=clang
Megans-MacBook-Pro:~ MeganRCunninghan$ export FFLAGS=-ff2c
Megans-MacBook-Pro:~ MeganRCunninghan$ git clone https://github.com/numpy/numpy.git
fatal: destination path 'numpy' already exists and is not an empty directory.
Megans-MacBook-Pro:~ MeganRCunninghan$ python setup.py build
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'setup.py': [Errno 2] No such file or directory
Megans-MacBook-Pro:~ MeganRCunninghan$ ls
Desktop     Dropbox     Pictures    my_new_env  virtualenv.pyc
Django      Library     Public      numpy
Documents   Movies      Sync Folder pip
Downloads   Music       git     virtualenv.py
Megans-MacBook-Pro:~ MeganRCunninghan$ cd numpy
Megans-MacBook-Pro:numpy MeganRCunninghan$ python setup.py build
Running from numpy source directory.
non-existing path in 'numpy/distutils': 'site.cfg'
F2PY Version 2
numpy/core/setup_common.py:86: MismatchCAPIWarning: API mismatch detected, the C API version numbers have to be updated. Current C api version is 8, with checksum f4362353e2d72f889fda0128aa015037, but recorded checksum for C API version 8 in codegen_dir/cversions.txt is 17321775fc884de0b1eda478cd61c74b. If functions were added in the C API, you have to update C_API_VERSION  in numpy/core/setup_common.py.
  MismatchCAPIWarning)
blas_opt_info:
  FOUND:
    extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
    define_macros = [('NO_ATLAS_INFO', 3)]
    extra_compile_args = ['-msse3', '-I/System/Library/Frameworks/vecLib.framework/Headers']

lapack_opt_info:
  FOUND:
    extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
    define_macros = [('NO_ATLAS_INFO', 3)]
    extra_compile_args = ['-msse3']

running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building py_modules sources
creating build
creating build/src.macosx-10.6-intel-2.7
creating build/src.macosx-10.6-intel-2.7/numpy
creating build/src.macosx-10.6-intel-2.7/numpy/distutils
building library "npymath" sources
customize Gnu95FCompiler
Could not locate executable gfortran
Could not locate executable f95
customize NAGFCompiler
customize AbsoftFCompiler
Could not locate executable f90
Could not locate executable f77
customize IBMFCompiler
Could not locate executable xlf90
Could not locate executable xlf
customize IntelFCompiler
Could not locate executable ifort
Could not locate executable ifc
customize GnuFCompiler
Could not locate executable g77
customize G95FCompiler
Could not locate executable g95
customize PGroupFCompiler
Could not locate executable pgfortran
don't know how to compile Fortran code on platform 'posix'
C compiler: clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3

compile options: '-Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c'
clang: _configtest.c
sh: clang: command not found
sh: clang: command not found
failure.
removing: _configtest.c _configtest.o
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/MeganRCunninghan/numpy/numpy/distutils/core.py", line 184, in setup
    return old_setup(**new_attr)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/Users/MeganRCunninghan/numpy/numpy/distutils/command/build.py", line 37, in run
    old_build.run(self)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build.py", line 127, in run
    self.run_command(cmd_name)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/Users/MeganRCunninghan/numpy/numpy/distutils/command/build_src.py", line 152, in run
    self.build_sources()
  File "/Users/MeganRCunninghan/numpy/numpy/distutils/command/build_src.py", line 163, in build_sources
    self.build_library_sources(*libname_info)
  File "/Users/MeganRCunninghan/numpy/numpy/distutils/command/build_src.py", line 298, in build_library_sources
    sources = self.generate_sources(sources, (lib_name, build_info))
  File "/Users/MeganRCunninghan/numpy/numpy/distutils/command/build_src.py", line 385, in generate_sources
    source = func(extension, build_dir)
  File "numpy/core/setup.py", line 644, in get_mathlib_info
    raise RuntimeError("Broken toolchain: cannot link a simple C program")
RuntimeError: Broken toolchain: cannot link a simple C program

我已经为此工作了几个小时,现在迷路了。

【问题讨论】:

  • 错误输出提示你没有安装clang? “sh:clang:找不到命令”。您可以在终端中运行“clang --version”吗?
  • new-host:~ MeganRCunninghan$ clang --version Apple clang 版本 2.1 (tags/Apple/clang-163.7.1) (基于 LLVM 3.0svn) 目标: x86_64-apple-darwin11.4.2线程模型:posix

标签: python xcode macos numpy python-2.7


【解决方案1】:

下载 Xcode 4 后,您需要让它安装其 Command Line Tools 组件。启动Xcode,然后选择Xcode -> Preferences -> Downloads -> Components。这将安装 clang 和其他构建工具,以便它们可以从命令行使用。

【讨论】:

  • 在组件字段下我会安装“命令行工具”吗?
  • 是的。另一方面,从您上面的新评论来看,您似乎已经安装了它们。尝试仍然不会有什么坏处。不幸的是,Numpy 有一个复杂的构建过程,因为它依赖于许多其他组件。如果您使用 Numpy 的二进制发行版或使用第三方包管理器(如 MacPorts 或 Homebrew)安装所有内容,从长远来看,您可能会过得更好。顺便说一句,你使用的是什么版本的 OS X?
  • 是的,我下载了这么多东西,我什至不知道是哪些组件让它现在工作哈哈,重要的是我让它工作了......成功安装、构建和导入耶!跨度>
【解决方案2】:

我最近遇到了类似的问题。我建议使用Homebrew 的 numpy 和 scipy 公式。它们将从源代码构建,但我对它们没有任何问题。

【讨论】:

  • 我会试试这个谢谢!我也意识到我下载了错误的 GCC。谢谢!
  • 是的,一旦我下载了正确的 GCC 和自制软件,它似乎就可以工作了!
【解决方案3】:

pip install numpy 没有问题。虽然你应该先install pip

【讨论】:

  • 我尝试了同样的错误。当我下载 Django 时,我已经安装了 pip。
【解决方案4】:

我也遇到了同样的问题!! 我通过使用 macports 安装 g95 Fortran 编译器解决了问题!
使用 macports 将其安装为 sudo port install g95 @0.92

【讨论】:

  • 那是我的下一个目标,但我下载了正确的 GCC 和自制软件,它现在似乎可以工作了
猜你喜欢
  • 1970-01-01
  • 2013-01-27
  • 1970-01-01
  • 2016-05-04
  • 1970-01-01
  • 1970-01-01
  • 2019-01-25
  • 2018-03-18
  • 1970-01-01
相关资源
最近更新 更多