0

我在 Python 2.7 中运行一个开源应用程序,混合了 Fortran F90 和 For 代码。我使用 Visual Studio 2019 和 Intel Parallel Studio 2019 集成。所以当我在 Intel CMD 中运行时python setup.py install出现此错误

error: Command "C:\Users\admin\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ibuild\src.win-amd64-2.7\build\src.win-amd64-2.7\scikits\scattpy -IC:\Python27amd64\lib\site-packages\numpy\core\include -IC:\Python27amd64\include -IC:\Python27amd64\PC /Tcbuild\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c /Fobuild\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.obj" failed with exit status 2

因为当我运行 test.pyNo module named f_utilsimport f_utilsspherical.py.

所以我该怎么做?任何帮助,将不胜感激。

设置.py:

#! /usr/bin/env python
# Last Change: Sun Dec 19 11:00 AM 2010 J

# Copyright (C) 2008 Alexander Vinokurov <alexander.a.vinokurov@gmail.com>

descr   = """ScattPy package.

ScattPy provides numerical methods for solving light scattering problem
by non-spherical particles.
"""

import os
import sys

DISTNAME            = 'scikits.scattpy'
DESCRIPTION         = 'Light Scattering methods for Python'
LONG_DESCRIPTION    = descr
MAINTAINER          = 'Alexander Vinokurov'
MAINTAINER_EMAIL    = 'scattpy@googlegroups.com'
URL                 = 'http://scattpy.github.com'
LICENSE             = 'BSD'
VERSION             = '0.1.2'
DOWNLOAD_URL        = 'http://github.com/downloads/ScattPy/scikits.scattpy/scikits.scattpy-'+VERSION+'.tar.gz'

import setuptools
from numpy.distutils.core import setup

def configuration(parent_package='', top_path=None, package_name=DISTNAME):
    if os.path.exists('MANIFEST'): os.remove('MANIFEST')

    from numpy.distutils.misc_util import Configuration
    config = Configuration(package_name, parent_package, top_path,
                           version = VERSION,
                           maintainer  = MAINTAINER,
                           maintainer_email = MAINTAINER_EMAIL,
                           description = DESCRIPTION,
                           license = LICENSE,
                           url = URL,
                           download_url = DOWNLOAD_URL,
                           long_description = LONG_DESCRIPTION)

    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_data_files("scikits/__init__.py")

#    config.add_extension('f_utils',
#                         sources=[os.path.join('src', 'f_utils.for')]
#                         )

    config.add_extension('f_utils',
                         sources=[os.path.join('src', 'f_utils.for')]
                         )
    config.add_extension('f_spheroid',
                         sources=[os.path.join('src', 'sdmn.f')]
                         )

    config.add_extension('f_radial',
        sources=[os.path.join('src', 'radial.for')],
        library_dirs=["lib"],
        libraries=["radial"]
    )

    return config

if __name__ == "__main__":
    setup(configuration = configuration,
        install_requires = 'numpy',
        namespace_packages = ['scikits'],
        packages = setuptools.find_packages(),
        include_package_data = True,
        #test_suite="tester", # for python setup.py test
        zip_safe = True, # the package can run out of an .egg file
        classifiers =
            [ 'Development Status :: 4 - Beta',
              'Environment :: Console',
              'Intended Audience :: Developers',
              'Intended Audience :: Science/Research',
              'Intended Audience :: Education',
              'License :: OSI Approved :: BSD License',
              'Topic :: Scientific/Engineering :: Mathematics',
              'Topic :: Scientific/Engineering :: Physics',
              'Topic :: Scientific/Engineering :: Astronomy', ])

我的英特尔 CMD:

Intel(R) Trace Analyzer and Collector 2019 Update 4 for Windows* OS for Intel(R) 64 applications
Copyright (C) 1996-2019 Intel Corporation. All rights reserved.

Invalid command line argument: vs2019


Intel(R) MPI Library 2019 Update 4 for Windows* Target Build Environment for Intel(R) 64 applications
Copyright 2007-2019 Intel Corporation.

Copyright (C) 1985-2019 Intel Corporation. All rights reserved.
Intel(R) Compiler 19.0 Update 4 (package 228)

**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.1.5
** Copyright (c) 2019 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

C:\Program Files (x86)\IntelSWTools>cd C:\Users\admin\Documents\GitHub\VSPY01\scikits.scattpy

C:\Users\admin\Documents\GitHub\VSPY01\scikits.scattpy>python setup.py install
non-existing path in '': 'lib'
running install
running bdist_egg
running egg_info
running build_src
build_src
building extension "scikits.scattpy.f_utils" sources
f2py options: []
  adding 'build\src.win-amd64-2.7\build\src.win-amd64-2.7\scikits\scattpy\fortranobject.c' to sources.
  adding 'build\src.win-amd64-2.7\build\src.win-amd64-2.7\scikits\scattpy' to include_dirs.
building extension "scikits.scattpy.f_spheroid" sources
f2py options: []
  adding 'build\src.win-amd64-2.7\build\src.win-amd64-2.7\scikits\scattpy\fortranobject.c' to sources.
  adding 'build\src.win-amd64-2.7\build\src.win-amd64-2.7\scikits\scattpy' to include_dirs.
building extension "scikits.scattpy.f_radial" sources
f2py options: []
  adding 'build\src.win-amd64-2.7\build\src.win-amd64-2.7\scikits\scattpy\fortranobject.c' to sources.
  adding 'build\src.win-amd64-2.7\build\src.win-amd64-2.7\scikits\scattpy' to include_dirs.
  adding 'build\src.win-amd64-2.7\scikits\scattpy\f_radial-f2pywrappers.f' to sources.
build_src: building npy-pkg config files
writing requirements to scikits.scattpy.egg-info\requires.txt
writing scikits.scattpy.egg-info\PKG-INFO
writing namespace_packages to scikits.scattpy.egg-info\namespace_packages.txt
writing top-level names to scikits.scattpy.egg-info\top_level.txt
writing dependency_links to scikits.scattpy.egg-info\dependency_links.txt
reading manifest file 'scikits.scattpy.egg-info\SOURCES.txt'
writing manifest file 'scikits.scattpy.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
running build_ext
customize MSVCCompiler
customize MSVCCompiler using build_ext
get_default_fcompiler: matching types: '['gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 'intelem', 'flang']'
customize GnuFCompiler
Could not locate executable g77
Could not locate executable f77
customize IntelVisualFCompiler
Found executable C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.228\windows\bin\intel64\ifort.exe
Could not locate executable C:\Program
customize AbsoftFCompiler
Could not locate executable f90
customize CompaqVisualFCompiler
Could not locate executable DF
customize IntelItaniumVisualFCompiler
Could not locate executable efl
customize Gnu95FCompiler
Could not locate executable gfortran
Could not locate executable f95
customize G95FCompiler
Could not locate executable g95
customize IntelEM64VisualFCompiler
customize IntelEM64VisualFCompiler
customize IntelEM64VisualFCompiler using build_ext
building 'scikits.scattpy.f_utils' extension
compiling C sources
creating build\temp.win-amd64-2.7\Release\build
creating build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7
creating build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\scikits
creating build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\scikits\scattpy
creating build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\build
creating build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\build\src.win-amd64-2.7
creating build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\build\src.win-amd64-2.7\scikits
creating build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\build\src.win-amd64-2.7\scikits\scattpy
C:\Users\admin\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ibuild\src.win-amd64-2.7\build\src.win-amd64-2.7\scikits\scattpy -IC:\Python27amd64\lib\site-packages\numpy\core\include -IC:\Python27amd64\include -IC:\Python27amd64\PC /Tcbuild\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c /Fobuild\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.obj
f_utilsmodule.c
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.21.27702\include\vcruntime.h(196) : error C2061: syntax error : identifier '__vcrt_bool'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.21.27702\include\vcruntime.h(196) : error C2059: syntax error : ';'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\corecrt.h(156) : error C2061: syntax error : identifier '__crt_bool'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\corecrt.h(156) : error C2059: syntax error : ';'
c:\python27amd64\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(14) : Warning Msg: Using deprecated NumPy API, disable it with #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(120) : warning C4244: '=' : conversion from 'npy_intp' to 'npy_int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(126) : warning C4244: '=' : conversion from 'npy_intp' to 'npy_int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(345) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(358) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(554) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(567) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(828) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(841) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(1095) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(1108) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(1341) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(1354) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(1594) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(1770) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(1932) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(2122) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(2373) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(2376) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(2713) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(2716) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(3069) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(3072) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(3438) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(3441) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(3830) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(3843) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(4260) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c(4293) : warning C4244: '=' : conversion from 'npy_intp' to 'int', possible loss of data
error: Command "C:\Users\admin\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ibuild\src.win-amd64-2.7\build\src.win-amd64-2.7\scikits\scattpy -IC:\Python27amd64\lib\site-packages\numpy\core\include -IC:\Python27amd64\include -IC:\Python27amd64\PC /Tcbuild\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.c /Fobuild\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\scikits\scattpy\f_utilsmodule.obj" failed with exit status 2

我的 test.py :

from numpy import *
from scikits.scattpy import *
P=ProlateSpheroid(ab=1.5,xv=1.0,m=1.33+0.07j)
LAB=Lab(P, pi/4)
RES=ebcm(LAB)

Csca_tm,Qsca_tm = LAB.get_Csca(RES.c_sca_tm)
print Csca_tm,Qsca_tm
Theta = linspace(0,pi,1000)
A = LAB.get_amplitude_matrix(RES.c_sca_tm,RES.c_sca_te,Theta,0)
S11g,S21_S11 = LAB.get_int_plr(A)
from matplotlib import pylab
pylab.semilogy(Theta*180/pi, S11g)
pylab.ylabel("S11/g")
pylab.xlabel("Theta")
pylab.title("Scattering field intencity")
pylab.show()
pylab.close()

pylab.plot(Theta*180/pi, S21_S11);
pylab.ylabel("S21/S11");
pylab.xlabel("Theta");
pylab.title("Scattering field degree of linear polarisation");
pylab.show()

Spherical.py 第一行:

from numpy import *
from scipy.special.orthogonal import ps_roots
from scipy import special
import f_utils

# (r, theta, phi)
class spherical_utilities(object):
    def __init__(self, ng, n, lab):
        self.n = n
        self.ng = ng
        self.set_ngauss()
        self.set_funcs_ang()
        self.set_all_layers(lab)

    def set_ngauss(self):
        k, w = ps_roots(self.ng)
        self.knots, self.weights = k * pi, w * pi
        self.thetas = self.knots
        self.sint = sin(self.thetas)
        self.cost = cos(self.thetas)
        self.tgt = tan(self.thetas)
        self.ctgt = 1 / self.tgt

f_utils.for 第一行:

      SUBROUTINE MAT_A0(NG,NN,Rad,Ang,coef,w,O)
      INTEGER    NG,NN
      COMPLEX*16 Rad(NG,NN)
      COMPLEX*16 Ang(NG,NN),coef(NG)
      COMPLEX*16 O(NN,NN)
      REAL*8     w(NG)
cf2py intent(in) Rad,Ang,coef,w
cf2py intent(out) O
cf2py intent(hide) NG,NN
      INTEGER    l,n,k

      DO l=1,NN
      DO n=1,NN
        O(l,n)=0d0
      ENDDO
      ENDDO

      DO k=1,NG
      DO l=1,NN
      DO n=1,NN
        O(l,n) = O(l,n) + Rad(k,l)*Ang(k,l)*Ang(k,n)*coef(k)*w(k)
      ENDDO
      ENDDO
      ENDDO
      END

      SUBROUTINE MAT_B(NG,NN,ki,Rad,Radd,Ang,Angd,R,Rdr,Sint,w,O)
      INTEGER    NG,NN

更新#1:

setup.py 中的这些行会导致错误:

config.add_extension('f_utils',
                     sources=[os.path.join('src', 'f_utils.for')]
                     )

更新#2:

当我改为Python 2.7并且Python 3.7python setup.py install得到这个错误时:

could not find library 'radial' in directories ['lib']...
LINK : fatal error LNK1181: cannot open input file 'radial.lib'
error: Command "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.21.27702\bin\HostX86\x64\link.exe...
… failed with exit status 1181
4

0 回答 0