1

所以我按照这个网站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

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

4

4 回答 4

5

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

于 2013-02-10T17:55:32.380 回答
1

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

于 2013-02-10T17:39:48.210 回答
0

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

于 2013-02-10T17:37:41.070 回答
0

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

于 2013-02-10T18:08:46.703 回答