我在使用setuptools在virtualenv中安装numpy时遇到了麻烦。我正在使用setup()以及通过install_requires传入的依赖项列表。其中一个依赖是numpy。我收到一个错误抱怨无法找到Python.h。然而,安装了python-dev软件包。运行:
locate Python.h
返回
/usr/include/python2.7/Python.h
如果我使用pip,我可以成功安装numpy。但我想要的是当我通过以下方式安装我自己的python模块时安装numpy:
python setup.py install
这是错误。安装Fortran编译器会删除Fortran错误,但仍会因缺少Python.h文件而崩溃。
Searching for numpy==1.8.0
Reading https://pypi.python.org/simple/numpy/
Best match: numpy 1.8.0
Downloading https://pypi.python.org/packages/source/n/numpy/numpy-1.8.0.zip#md5=6c918bb91c0cfa055b16b13850cfcd6e
Processing numpy-1.8.0.zip
Writing /tmp/easy_install-lSyucn/numpy-1.8.0/setup.cfg
Running numpy-1.8.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-lSyucn/numpy-1.8.0/egg-dist-tmp-8m2hid
Running from numpy source directory.
Warning: distutils distribution has been initialized, it may be too late to add a subpackage commandWarning: distutils distribution has been initialized, it may be too late to add a subpackage fcompilernon-existing path in 'numpy/distutils': 'site.cfg'
Warning: distutils distribution has been initialized, it may be too late to add a subpackage distutilsWarning: distutils distribution has been initialized, it may be too late to add a subpackage testingWarning: distutils distribution has been initialized, it may be too late to add a subpackage f2pyWarning: distutils distribution has been initialized, it may be too late to add an extension _dummyWarning: distutils distribution has been initialized, it may be too late to add a library npysortWarning: distutils distribution has been initialized, it may be too late to add an extension multiarrayWarning: distutils distribution has been initialized, it may be too late to add an extension umathWarning: distutils distribution has been initialized, it may be too late to add an extension scalarmath/tmp/easy_install-lSyucn/numpy-1.8.0/numpy/distutils/system_info.py:1522: 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__)
/tmp/easy_install-lSyucn/numpy-1.8.0/numpy/distutils/system_info.py:1531: 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__)
/tmp/easy_install-lSyucn/numpy-1.8.0/numpy/distutils/system_info.py:1534: 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__)
Warning: distutils distribution has been initialized, it may be too late to add an extension _dotblasWarning: distutils distribution has been initialized, it may be too late to add an extension umath_testsWarning: distutils distribution has been initialized, it may be too late to add an extension test_rationalWarning: distutils distribution has been initialized, it may be too late to add an extension struct_ufunc_testWarning: distutils distribution has been initialized, it may be too late to add an extension multiarray_testsWarning: distutils distribution has been initialized, it may be too late to add an extension operand_flag_testsWarning: distutils distribution has been initialized, it may be too late to add a subpackage coreWarning: distutils distribution has been initialized, it may be too late to add an extension _compiled_basenon-existing path in 'numpy/lib': 'benchmarks'
Warning: distutils distribution has been initialized, it may be too late to add a subpackage libWarning: distutils distribution has been initialized, it may be too late to add a subpackage oldnumericWarning: distutils distribution has been initialized, it may be too late to add an extension _capiWarning: distutils distribution has been initialized, it may be too late to add a subpackage numarrayWarning: distutils distribution has been initialized, it may be too late to add an extension fftpack_liteWarning: distutils distribution has been initialized, it may be too late to add a subpackage fft/tmp/easy_install-lSyucn/numpy-1.8.0/numpy/distutils/system_info.py:1428: 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__)
/tmp/easy_install-lSyucn/numpy-1.8.0/numpy/distutils/system_info.py:1439: 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__)
/tmp/easy_install-lSyucn/numpy-1.8.0/numpy/distutils/system_info.py:1442: 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__)
Warning: distutils distribution has been initialized, it may be too late to add an extension lapack_liteWarning: distutils distribution has been initialized, it may be too late to add an extension _umath_linalgWarning: distutils distribution has been initialized, it may be too late to add a subpackage linalgWarning: distutils distribution has been initialized, it may be too late to add an extension mtrandWarning: distutils distribution has been initialized, it may be too late to add a subpackage randomWarning: distutils distribution has been initialized, it may be too late to add a subpackage maWarning: distutils distribution has been initialized, it may be too late to add a subpackage matrixlibWarning: distutils distribution has been initialized, it may be too late to add a subpackage compatWarning: distutils distribution has been initialized, it may be too late to add a subpackage polynomialWarning: distutils distribution has been initialized, it may be too late to add a subpackage docWarning: distutils distribution has been initialized, it may be too late to add a subpackage numpyCould not locate executable gfortran
Could not locate executable f95
Could not locate executable ifort
Could not locate executable ifc
Could not locate executable lf95
Could not locate executable pgfortran
Could not locate executable f90
Could not locate executable f77
Could not locate executable fort
Could not locate executable efort
Could not locate executable efc
Could not locate executable g77
Could not locate executable g95
Could not locate executable pathf95
don't know how to compile Fortran code on platform 'posix'
_configtest.c:1:5: warning: conflicting types for built-in function ‘exp’ [enabled by default]
_configtest.o: In function `main':
/tmp/easy_install-lSyucn/numpy-1.8.0/_configtest.c:6: undefined reference to `exp'
collect2: error: ld returned 1 exit status
_configtest.o: In function `main':
/tmp/easy_install-lSyucn/numpy-1.8.0/_configtest.c:6: undefined reference to `exp'
collect2: error: ld returned 1 exit status
_configtest.c:1:5: warning: conflicting types for built-in function ‘exp’ [enabled by default]
_configtest.c:1:20: fatal error: Python.h: No such file or directory
compilation terminated.
_configtest.c:1:20: fatal error: Python.h: No such file or directory
compilation terminated.
Traceback (most recent call last):
File "setup.py", line 178, in <module>
install_app()
File "setup.py", line 119, in install_app
entry_points=ENTRY_POINTS
File "/usr/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "build/bdist.linux-x86_64/egg/setuptools/command/develop.py", line 27, in run
File "build/bdist.linux-x86_64/egg/setuptools/command/develop.py", line 129, in install_for_development
File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 687, in process_distribution
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 568, in resolve
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 806, in best_match
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 818, in obtain
File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 609, in easy_install
File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 639, in install_item
File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 825, in install_eggs
File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 1031, in build_and_install
File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 1016, in run_setup
File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 69, in run_setup
File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 120, in run
File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 71, in <lambda>
File "setup.py", line 192, in <module>
File "setup.py", line 185, in setup_package
File "/tmp/easy_install-lSyucn/numpy-1.8.0/numpy/distutils/core.py", line 169, in setup
File "/usr/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "build/bdist.linux-x86_64/egg/setuptools/command/bdist_egg.py", line 177, in run
File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/tmp/easy_install-lSyucn/numpy-1.8.0/numpy/distutils/command/egg_info.py", line 10, in run
File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/tmp/easy_install-lSyucn/numpy-1.8.0/numpy/distutils/command/build_src.py", line 153, in run
File "/tmp/easy_install-lSyucn/numpy-1.8.0/numpy/distutils/command/build_src.py", line 170, in build_sources
File "/tmp/easy_install-lSyucn/numpy-1.8.0/numpy/distutils/command/build_src.py", line 329, in build_extension_sources
File "/tmp/easy_install-lSyucn/numpy-1.8.0/numpy/distutils/command/build_src.py", line 386, in generate_sources
File "numpy/core/setup.py", line 427, in generate_config_h
File "numpy/core/setup.py", line 42, in check_types
File "numpy/core/setup.py", line 288, in check_types
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
这些是我正在使用的版本:
Ubuntu: 12.10
Setuptools: 1.4.2
Numpy: 1.8.0
答案 0 :(得分:0)
看起来您没有安装Fortran编译器。试试apt-get install gfortran
。