How to install numpy 1.8 dev on Windows?

2019-06-05 22:56发布

问题:

I'm trying to install numpy 1.8 dev on Windows. I cannot find any binaries, only 1.7.1. Does anyone know where to download it?

Alternatively, I also tried to build numpy myself. I donwloaded the latest source from Github and ran python setup.py install, but I get an error RuntimeError: Broken toolchain: cannot link a simple C program. Here's some of the output. I have VS 2008 installed with both 32x and 64x compilers as well as MinGW 32x.

C:\numpy-master\numpy\distutils\system_info.py:1429: UserWarning:
    Lapack (http://www.netlib.org/lapack/) sources not found.
    Directories to search for the sources can be specified in the
    numpy/distutils/site.cfg file (section [lapack_src]) or by setting
    the LAPACK_SRC environment variable.
  warnings.warn(LapackSrcNotFoundError.__doc__)
  NOT AVAILABLE

running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler opt
ons
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler op
ions
running build_src
build_src
building py_modules sources
building library "npymath" sources
customize GnuFCompiler
Could not locate executable g77
Could not locate executable f77
customize IntelVisualFCompiler
Could not locate executable ifort
Could not locate executable ifl
customize AbsoftFCompiler
Could not locate executable f90
customize CompaqVisualFCompiler
Could not locate executable DF
customize IntelItaniumVisualFCompiler
Could not locate executable efl
customize Gnu95FCompiler
Found executable C:\Python27\Scripts\gfortran.exe
Found executable C:\Python27\Scripts\gfortran.exe
customize Gnu95FCompiler
customize Gnu95FCompiler using config
C compiler: gcc -O2 -Wall -Wstrict-prototypes

compile options: '-DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x0900 -Inu
py\core\src\private -Inumpy\core\src -Inumpy\core -Inumpy\core\src\npymath -Inu
py\core\src\multiarray -Inumpy\core\src\umath -Inumpy\core\src\npysort -Inumpy\
ore\include -IC:\Python27\include -IC:\Python27\PC -c'
gcc -O2 -Wall -Wstrict-prototypes -DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSI
N__=0x0900 -Inumpy\core\src\private -Inumpy\core\src -Inumpy\core -Inumpy\core\
rc\npymath -Inumpy\core\src\multiarray -Inumpy\core\src\umath -Inumpy\core\src\
pysort -Inumpy\core\include -IC:\Python27\include -IC:\Python27\PC -c _configte
t.c -o _configtest.o
Found executable C:\Python27\Scripts\gcc.exe
g++ _configtest.o -lmsvcr90 -o _configtest.exe
Found executable C:\Python27\Scripts\g++.exe
c:/python27/egg-info/mingw/usr/bin/../lib/gcc/i686-w64-mingw32/4.5.2/../../../.
/i686-w64-mingw32/bin/ld.exe: cannot find -lmsvcr90
collect2: ld returned 1 exit status
failure.
removing: _configtest.exe.manifest _configtest.c _configtest.o
Traceback (most recent call last):
  File "setup.py", line 216, in <module>
    setup_package()
  File "setup.py", line 209, in setup_package
    configuration=configuration )
  File "C:\numpy-master\numpy\distutils\core.py", line 169, in setup
    return old_setup(**new_attr)
  File "C:\Python27\lib\distutils\core.py", line 152, in setup
    dist.run_commands()
  File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\numpy-master\numpy\distutils\command\build.py", line 39, in run
    old_build.run(self)
  File "C:\Python27\lib\distutils\command\build.py", line 127, in run
    self.run_command(cmd_name)
  File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\numpy-master\numpy\distutils\command\build_src.py", line 153, in run
    self.build_sources()
  File "C:\numpy-master\numpy\distutils\command\build_src.py", line 164, in bui
d_sources
    self.build_library_sources(*libname_info)
  File "C:\numpy-master\numpy\distutils\command\build_src.py", line 299, in bui
d_library_sources
    sources = self.generate_sources(sources, (lib_name, build_info))
  File "C:\numpy-master\numpy\distutils\command\build_src.py", line 386, in gen
rate_sources
    source = func(extension, build_dir)
  File "numpy\core\setup.py", line 646, in get_mathlib_info
    raise RuntimeError("Broken toolchain: cannot link a simple C program")
RuntimeError: Broken toolchain: cannot link a simple C program

C:\numpy-master>python setup.py install
Running from numpy source directory.
non-existing path in 'numpy\\distutils': 'site.cfg'
F2PY Version 2
numpy\core\setup_common.py:88: MismatchCAPIWarning: API mismatch detected, the
 API version numbers have to be updated. Current C api version is 8, with check
um f4362353e2d72f889fda0128aa015037, but recorded checksum for C API version 8
n codegen_dir/cversions.txt is 17321775fc884de0b1eda478cd61c74b. If functions w
re added in the C API, you have to update C_API_VERSION  in numpy\core\setup_co
mon.pyc.
  MismatchCAPIWarning)
blas_opt_info:
blas_mkl_info:
  libraries mkl,vml,guide not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Pytho
27\\libs']
  NOT AVAILABLE

atlas_blas_threads_info:
Setting PTATLAS=ATLAS
  libraries ptf77blas,ptcblas,atlas not found in ['C:\\Python27\\lib', 'C:\\',
C:\\Python27\\libs']
  NOT AVAILABLE

atlas_blas_info:
  libraries f77blas,cblas,atlas not found in ['C:\\Python27\\lib', 'C:\\', 'C:\
Python27\\libs']
  NOT AVAILABLE

C:\numpy-master\numpy\distutils\system_info.py:1501: UserWarning:
    Atlas (http://math-atlas.sourceforge.net/) libraries not found.
    Directories to search for the libraries can be specified in the
    numpy/distutils/site.cfg file (section [atlas]) or by setting
    the ATLAS environment variable.
  warnings.warn(AtlasNotFoundError.__doc__)
blas_info:
  libraries blas not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python27\\libs
]
  NOT AVAILABLE

C:\numpy-master\numpy\distutils\system_info.py:1510: UserWarning:
    Blas (http://www.netlib.org/blas/) libraries not found.
    Directories to search for the libraries can be specified in the
    numpy/distutils/site.cfg file (section [blas]) or by setting
    the BLAS environment variable.
  warnings.warn(BlasNotFoundError.__doc__)
blas_src_info:
  NOT AVAILABLE

C:\numpy-master\numpy\distutils\system_info.py:1513: UserWarning:
    Blas (http://www.netlib.org/blas/) sources not found.
    Directories to search for the sources can be specified in the
    numpy/distutils/site.cfg file (section [blas_src]) or by setting
    the BLAS_SRC environment variable.
  warnings.warn(BlasSrcNotFoundError.__doc__)
  NOT AVAILABLE

non-existing path in 'numpy\\lib': 'benchmarks'
lapack_opt_info:
lapack_mkl_info:
mkl_info:
  libraries mkl,vml,guide not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Pytho
27\\libs']
  NOT AVAILABLE

  NOT AVAILABLE

atlas_threads_info:
Setting PTATLAS=ATLAS
  libraries ptf77blas,ptcblas,atlas not found in C:\Python27\lib
  libraries lapack_atlas not found in C:\Python27\lib
  libraries ptf77blas,ptcblas,atlas not found in C:\
  libraries lapack_atlas not found in C:\
  libraries ptf77blas,ptcblas,atlas not found in C:\Python27\libs
  libraries lapack_atlas not found in C:\Python27\libs
numpy.distutils.system_info.atlas_threads_info
  NOT AVAILABLE

atlas_info:
  libraries f77blas,cblas,atlas not found in C:\Python27\lib
  libraries lapack_atlas not found in C:\Python27\lib
  libraries f77blas,cblas,atlas not found in C:\
  libraries lapack_atlas not found in C:\
  libraries f77blas,cblas,atlas not found in C:\Python27\libs
  libraries lapack_atlas not found in C:\Python27\libs
numpy.distutils.system_info.atlas_info
  NOT AVAILABLE

C:\numpy-master\numpy\distutils\system_info.py:1415: UserWarning:
    Atlas (http://math-atlas.sourceforge.net/) libraries not found.
    Directories to search for the libraries can be specified in the
    numpy/distutils/site.cfg file (section [atlas]) or by setting
    the ATLAS environment variable.
  warnings.warn(AtlasNotFoundError.__doc__)
lapack_info:
  libraries lapack not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python27\\li
s']
  NOT AVAILABLE

C:\numpy-master\numpy\distutils\system_info.py:1426: UserWarning:
    Lapack (http://www.netlib.org/lapack/) libraries not found.
    Directories to search for the libraries can be specified in the
    numpy/distutils/site.cfg file (section [lapack]) or by setting
    the LAPACK environment variable.
  warnings.warn(LapackNotFoundError.__doc__)
lapack_src_info:
  NOT AVAILABLE

C:\numpy-master\numpy\distutils\system_info.py:1429: UserWarning:
    Lapack (http://www.netlib.org/lapack/) sources not found.
    Directories to search for the sources can be specified in the
    numpy/distutils/site.cfg file (section [lapack_src]) or by setting
    the LAPACK_SRC environment variable.
  warnings.warn(LapackSrcNotFoundError.__doc__)
  NOT AVAILABLE

running install
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler opt
ons
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler op
ions
running build_src
build_src
building py_modules sources
building library "npymath" sources
customize GnuFCompiler
Could not locate executable g77
Could not locate executable f77
customize IntelVisualFCompiler
Could not locate executable ifort
Could not locate executable ifl
customize AbsoftFCompiler
Could not locate executable f90
customize CompaqVisualFCompiler
Could not locate executable DF
customize IntelItaniumVisualFCompiler
Could not locate executable efl
customize Gnu95FCompiler
Found executable C:\Python27\Scripts\gfortran.exe
Found executable C:\Python27\Scripts\gfortran.exe
customize Gnu95FCompiler
customize Gnu95FCompiler using config
C compiler: gcc -O2 -Wall -Wstrict-prototypes

    compile options: '-DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x0900 -Inu
    py\core\src\private -Inumpy\core\src -Inumpy\core -Inumpy\core\src\npymath -Inu
    py\core\src\multiarray -Inumpy\core\src\umath -Inumpy\core\src\npysort -Inumpy\
    ore\include -IC:\Python27\include -IC:\Python27\PC -c'
    gcc -O2 -Wall -Wstrict-prototypes -DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSI
    N__=0x0900 -Inumpy\core\src\private -Inumpy\core\src -Inumpy\core -Inumpy\core\
    rc\npymath -Inumpy\core\src\multiarray -Inumpy\core\src\umath -Inumpy\core\src\
    pysort -Inumpy\core\include -IC:\Python27\include -IC:\Python27\PC -c _configte
    t.c -o _configtest.o
    Found executable C:\Python27\Scripts\gcc.exe
    g++ _configtest.o -lmsvcr90 -o _configtest.exe
    Found executable C:\Python27\Scripts\g++.exe
    c:/python27/egg-info/mingw/usr/bin/../lib/gcc/i686-w64-mingw32/4.5.2/../../../.
    /i686-w64-mingw32/bin/ld.exe: cannot find -lmsvcr90
    collect2: ld returned 1 exit status
    failure.
    removing: _configtest.exe.manifest _configtest.c _configtest.o
    Traceback (most recent call last):
      File "setup.py", line 216, in <module>
        setup_package()
      File "setup.py", line 209, in setup_package
        configuration=configuration )
      File "C:\numpy-master\numpy\distutils\core.py", line 169, in setup
        return old_setup(**new_attr)
      File "C:\Python27\lib\distutils\core.py", line 152, in setup
        dist.run_commands()
      File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
        cmd_obj.run()
      File "C:\numpy-master\numpy\distutils\command\install.py", line 57, in run
        r = old_install.run(self)
      File "C:\Python27\lib\distutils\command\install.py", line 563, in run
        self.run_command('build')
      File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
        cmd_obj.run()
      File "C:\numpy-master\numpy\distutils\command\build.py", line 39, in run
        old_build.run(self)
      File "C:\Python27\lib\distutils\command\build.py", line 127, in run
        self.run_command(cmd_name)
      File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
        cmd_obj.run()
      File "C:\numpy-master\numpy\distutils\command\build_src.py", line 153, in run
        self.build_sources()
      File "C:\numpy-master\numpy\distutils\command\build_src.py", line 164, in bui
    d_sources
        self.build_library_sources(*libname_info)
      File "C:\numpy-master\numpy\distutils\command\build_src.py", line 299, in bui
    d_library_sources
        sources = self.generate_sources(sources, (lib_name, build_info))
      File "C:\numpy-master\numpy\distutils\command\build_src.py", line 386, in gen
    rate_sources
        source = func(extension, build_dir)
      File "numpy\core\setup.py", line 646, in get_mathlib_info
        raise RuntimeError("Broken toolchain: cannot link a simple C program")
    RuntimeError: Broken toolchain: cannot link a simple C program

回答1:

I've solved it.

First make sure you have Visual Studio 2008 installed and possibly MinGW. Then you need to install http://software.intel.com/en-us/intel-mkl then need to create a site.cfg file under your numpy/distutils/ in your source. add this to it

[mkl]
include_dirs = C:\Program Files (x86)\Intel\Composer XE 2013\mkl\include
library_dirs = C:\Program Files (x86)\Intel\Composer XE 2013\mkl\lib\ia32
mkl_libs = mkl_ia32, mkl_c_dll, libguide40
lapack_libs = mkl_lapack

Then go to your python installation to C:\Python27\Lib\distutils\distutils.cfg Make sure it's empty! and has no such things as

[build]
compiler=mingw32

This will throw off your installer. You can add C:\MinGW\bin to the Path, not sure if this is needed though. Finally, go back to your numpy source directory and run python setup.py install. Should compile without errors.