简体   繁体   中英

Numpy Install/Build Mac Osx

So I followed the directions on this website http://www.scipy.org/Installing_SciPy/Mac_OS_X , downloaded Xcode and Fortran Gcc and then ran the following from the terminal:

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

I have been working on this for hours, so lost now.

After you download Xcode 4, you then need to have it install its Command Line Tools component. Launch Xcode , then choose Xcode -> Preferences -> Downloads -> Components . That will install clang and other build tools so they are available from the command line.

I recently had a similar problem. I recommend using Homebrew 's numpy and scipy formulas. They will build from source, but I had no problem with them.

I had no problem with pip install numpy . Though you should install pip first.

I was facing the same issue!! i resolved by installing g95 Fortran compiler with macports!
use macports to install it as sudo port install g95 @0.92

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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