Python Error : File ... spherical.py... import f_utils...ImportError: DLL load failed: The specified module could not be found

Python Error : File ... spherical.py... import f_utils...ImportError: DLL load failed: The specified module could not be found

我正在 运行python 2.7 中使用 MIN-GW - gfortranfortran77 代码和 Visual Studio 2010 中的一些代码。我安装了所有pip 的要求,所以当我这样做时:

python setup.py install

一切成功

f2py -c f_utils.for

创建

libf_utils.DLYOMDEGIW6SZRJNEZ2ZMRYPGQZ75ZH3.gfortran-win_amd64.dll..\untitled\.libsuntitled.pyd

但是作为 python spherical.py install 现在我得到这个错误:

Traceback (most recent call last):
  File "spherical.py", line 4, in <module>
    import f_utils
ImportError: DLL load failed: The specified module could not be found.

所以我正在寻找解决方案。任何帮助将不胜感激。

setup.py:

import os
import sys

...    
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_extension('f_utils',
                         sources=[os.path.join('src', 'f_utils.for')]
                         )

    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 =
            [ ...

我的第一行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

         …

我的第一行spherical.py:

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

   …
    def matA0(C,m,jh,i,coef):
           Rad = C.Rad(m,jh,i)
           Angm = C.Ang(m)
           #func = lambda k:  outer( Rad[k]*Angm[k], coef[k]*Angm[k])
           #return mat_integrate(func)
           return f_utils.mat_a0(Rad,Angm,coef,C.weights)

…

更新#1:

1) 因为我想在 https://docs.scipy.org/doc/numpy/f2py/getting-started.html 中 运行 示例,所以我卸载了这些:Min-GWpython 2.7 以及任何 visual Studio 软件。所以我清理了与 python 2.7

相关的所有文件

2) 然后我安装 Visual Studio 2019Intel Parallel Studio 2019python 3.7.0 (64 bit) 并勾选 python 路径,还安装 python 所需的软件包,例如 numpy

3) 然后将路径设置为 C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.228\windows\compiler\lib\intel64

4) 然后按照 https://docs.scipy.org/doc/numpy/f2py/getting-started.html 中的结构为 fib1 设置,同时为 print 函数设置 ()

那么一切都成功了。

由于我使用的指令与下面的指令稍作修改,spherical.py可以成功执行,没有错误。

1) 作为 https://docs.scipy.org/doc/numpy/f2py/getting-started.html 中的示例,我卸载了这些:Min-GWpython 2.7 以及任何 visual Studio 软件。所以我清理了与 python 2.7

相关的所有文件

2) 然后我安装 Visual Studio 2019Intel Parallel Studio 2019python 3.7.0 (64 bit) 并勾选 python 路径,还安装 python 所需的软件包,例如 numpy

3) 然后将路径设置为 C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.228\windows\compiler\lib\intel64

4) 然后按照 https://docs.scipy.org/doc/numpy/f2py/getting-started.html 中的结构为 fib1 做,也为 print 函数设置 ()

那么一切都成功了。