如何修复由于在Cygwin中找不到合适的Fortran编译器而失败的Python扩展构建?

2024-10-03 17:29:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试安装一个Python扩展(hydroclimpy.sourceforge.net)显然需要在安装之前编译一些Fortran。当我为扩展运行build命令时,最后出现一个错误,告诉我找不到合适的Fortran编译器:

$ c:/Python27/Python.exe setup.py build
non-existing path in 'scikits\\hydroclimpy': 'hydroclimpyrc.template'
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 extension "scikits.hydroclimpy.stats._lmoments" sources
f2py options: []
  adding 'build\src.win32-2.7\fortranobject.c' to sources.
  adding 'build\src.win32-2.7' to include_dirs.
  adding 'build\src.win32-2.7\scikits\hydroclimpy\stats\_lmoments-f2pywrappers.f' to sources.
building data_files sources
build_src: building npy-pkg config files
running build_py
running build_ext
No module named msvccompiler in numpy.distutils; trying from distutils
customize MSVCCompiler
customize MSVCCompiler using build_ext
customize GnuFCompiler
Found executable C:\cygwin\bin\g77.exe
gnu: no Fortran 90 compiler found
gnu: no Fortran 90 compiler found
Found executable C:\cygwin\bin\g77.exe
customize IntelVisualFCompiler
Could not locate executable ifort
Could not locate executable ifl
customize AbsoftFCompiler
Could not locate executable f90
Found executable C:\cygwin\bin\f77.exe
absoft: no Fortran 90 compiler found
absoft: no Fortran 90 compiler found
customize CompaqVisualFCompiler
Found executable C:\cygwin\bin\DF.exe
Found executable C:\cygwin\bin\DF.exe
customize IntelItaniumVisualFCompiler
Could not locate executable efl
customize Gnu95FCompiler
Found executable C:\cygwin\bin\gfortran.exe
Found executable C:\cygwin\bin\gfortran.exe
customize G95FCompiler
Could not locate executable g95
customize IntelEM64VisualFCompiler
customize IntelEM64TFCompiler
Could not locate executable efort
Could not locate executable efc
don't know how to compile Fortran code on platform 'nt'
warning: build_ext: f77_compiler=None is not available.

building 'scikits.hydroclimpy.stats._lmoments' extension
error: extension 'scikits.hydroclimpy.stats._lmoments' has Fortran sources but no Fortran compiler found

我的机器是一个带有Cygwin的windowsxp设备。安装工具已安装。我已经安装了g95以及在Cygwin的安装列表中找到的与Fortran相关的任何东西。/usr/local/bin显示g95和gfortran:

^{pr2}$

有人能给我一些建议吗?我可以试着把这台机器上的Fortran情况弄清楚,让这个扩展的设置脚本按预期工作?在

如果有帮助,此扩展的安装脚本如下:

"""
:mod:`scikits.hydroclimpy`
--------------------------

A collection of tools to manipulate environmental and climatologic time series.

setuptools must be installed first. If you do not have setuptools installed
please download and install it from http://pypi.python.org/pypi/setuptools
"""

version = '0.67.1'

classifiers = ['Development Status :: 4 - Beta',
               'Intended Audience :: Science/Research',
               'Intended Audience :: Developers',
               'License :: OSI Approved :: BSD License',
               'Operating System :: Microsoft :: Windows',
               'Operating System :: POSIX',
               'Operating System :: Unix',
               'Operating System :: MacOS',
               'Programming Language :: C',
               'Programming Language :: Python',
               'Topic :: Education',
               'Topic :: Scientific/Engineering',
               'Topic :: Software Development',
              ]

distname = 'scikits.hydroclimpy'

long_description = """
The scikits.hydroclimpy module is a collection of tools for manipulating and 
plotting environmental time series of various frequencies. This package is 
an extension for scikits.timeseries, focusing on tools for the analysis of
hydroclimatologic datasets.
"""

import os
import sys
import setuptools
from numpy.distutils.core import setup, Extension


def configuration(parent_package='',top_path=None):
    from numpy.distutils.misc_util import Configuration
    config = Configuration(None, parent_package, top_path,
                           namespace_packages=['scikits'])

    config.set_options(ignore_setup_xxx_py=True,
                       assume_default_configuration=True,
                       delegate_options_to_subpackages=True,
                       quiet=True,
    )

    config.add_subpackage('scikits')
    config.add_subpackage('doc')
    config.add_subpackage('examples')
    config.add_subpackage(distname)
    config.add_data_files('scikits/__init__.py')

    return config

package_data = {'': 'hydroclimpyrc'}

def setup_package():

    setup(
          install_requires=['numpy > 1.2.5',
                            'scipy >= 0.7',
                            'scikits.timeseries >= 0.91'],
          namespace_packages=['scikits'],
          packages=setuptools.find_packages(),
          test_suite = 'nose.collector',
          name = distname,
          version = version,
          description = "Environmental time series manipulation",
          long_description = long_description,
          license = "BSD",
          author = "Pierre GF GERARD-MARCHANT",
          author_email = "pierregmcode_AT_gmail_DOT_com",
          maintainer = "Pierre GF GERARD-MARCHANT",
          maintainer_email = "pierregmcode_AT_gmail_DOT_com",
          url = "http://hydroclimpy.sourceforge.net",
          classifiers = classifiers,
          platforms = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"],
          configuration = configuration,
    )

    return

if __name__ == '__main__':
    setup_package()

Tags: buildconfigbincompilernotexelocatecould
2条回答

您可能想尝试在this python bug中应用该补丁,这允许我在遇到与您描述的完全相同的错误后从源代码构建numpy。在

注意:我是用VS2010编译的,您应该在所有python扩展中也使用它。在

另一个不同的建议是:避免cygwin之类的问题,并试图在XP设备上获得一个*nix之类的环境的一种方法是尝试使用linux。有很多方法可以做到这一点,包括双引导,livelinux,或者直接去做。在

相关问题 更多 >