3

我正在尝试安装一个 Python 扩展(hydroclimpy.sourceforge.net),它显然需要在安装之前将一些 Fortran 编译到自身中。当我为扩展运行构建命令时,我得到一个错误,告诉我没有找到合适的 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 的 Windows XP 机器。安装工具已安装。我已经安装了 g95 以及我在 Cygwin 的安装列表中找到的任何其他东西,它们看起来与 Fortran 相关。/usr/local/bin 显示 g95 和 gfortran:

$ ls -l /usr/local/bin/
total 159
lrwxrwxrwx 1 James None     52 Nov 13 14:07 cc1 -> /usr/local/lib/gcc-lib/i686-pc-cygwin/4.1.2/f951.
exe
lrwxrwxrwx 1 James None     37 Nov 13 14:07 g95 -> /usr/local/bin/i686-pc-cygwin-g95.exe
lrwxrwxrwx 1 James None     36 Aug 23 11:54 gfortran -> /usr/local/gfortran/bin/gfortran.exe
-rwxr-xr-x 1 James None 158895 Nov 13 14:07 i686-pc-cygwin-g95.exe

任何人都可以提出其他建议吗?我可以尝试以一种使该扩展的安装脚本按预期工作的方式对这台机器上的 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()
4

2 回答 2

0

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

注意:我正在使用 VS2010 进行编译,您也应该将它用于所有 python 扩展。

于 2014-07-25T12:26:18.103 回答
0

来自不同观点的替代建议:避免 cygwin 之类的问题并尝试在 XP 机器上获得类似 *nix 的环境的一种方法是尝试使用 linux。有很多方法可以做到这一点,包括双启动、实时 linux,或者只是去做。

于 2012-11-29T06:50:57.400 回答