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

心已入冬 提交于 2019-12-12 06:43:30

问题


I am running some codes in python 2.7 with MIN-GW - gfortran of fortran77 codes and Visual Studio 2010.I installed all requirements with pip, so when I do this:

python setup.py install

everything is successful.

f2py -c f_utils.for

Creates

libf_utils.DLYOMDEGIW6SZRJNEZ2ZMRYPGQZ75ZH3.gfortran-win_amd64.dll in ..\untitled\.libs and untitled.pyd

but As python spherical.py install Now I get this error:

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.

So I am searching for a solution for that. Any help would be appreciated.

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

first lines of my 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

         …

first lines of my 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)

…

UPDATE #1:

1) As I want to run sample in https://docs.scipy.org/doc/numpy/f2py/getting-started.html , I uninstall These : Min-GW and python 2.7 and any visual Studio software's . So I cleaned all Files related to python 2.7

2) Then I install Visual Studio 2019 and Intel Parallel Studio 2019 and python 3.7.0 (64 bit) with checkmark for python path ,also install packages needed for python such as numpy

3) then set a Path to C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.228\windows\compiler\lib\intel64

4) then Do as the structure as in the https://docs.scipy.org/doc/numpy/f2py/getting-started.html for fib1, also set () for print function.

then everything is successful.


回答1:


As I used instruction same as below with a little modification , spherical.py could execute successfully, with no errors.

1) As sample in https://docs.scipy.org/doc/numpy/f2py/getting-started.html , I uninstall These : Min-GW and python 2.7 and any visual Studio software's . So I cleaned all Files related to python 2.7

2) Then I install Visual Studio 2019 and Intel Parallel Studio 2019 and python 3.7.0 (64 bit) with checkmark for python path ,also install packages needed for python such as numpy

3) then set a Path to C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.228\windows\compiler\lib\intel64

4) then Do as the structure as in the https://docs.scipy.org/doc/numpy/f2py/getting-started.html for fib1, also set () for print function.

then everything is successful.



来源:https://stackoverflow.com/questions/57300786/python-error-file-spherical-py-import-f-utils-importerror-dll-load-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!