-1

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.

  • That is done. I named that `f_utils.pyd` and test that ,the problem still exists . But I don't know how to import my `dll` or `pyd` into my `py` codes with `import` . – Fortran Python Developer Aug 03 '19 at 03:07
  • `Traceback (most recent call last): File "", line 1, in ImportError: DLL load failed: The specified module could not be found.` – Fortran Python Developer Aug 04 '19 at 17:40
  • As now I couldn't execute small samples on https://docs.scipy.org/doc/numpy/f2py/usage.html#python-module-numpy-f2py and https://docs.scipy.org/doc/numpy/f2py/getting-started.html . So maybe the problem is with my Python and compilers ,or version conflicts or incompatibility. I am playing with Fortran compilers ,VS and Python and it's packages such as numpy ,f2py and so far. – Fortran Python Developer Aug 05 '19 at 04:21
  • [TEST SOLVED] .My small Fortran & Python program worked successfully. Later I would place them in the text.It had a lot of difficulties. – Fortran Python Developer Aug 05 '19 at 10:49
  • In `UPDATE #1` I shows how to run https://docs.scipy.org/doc/numpy/f2py/getting-started.html for `fib1` . If anything is unclear let me know. – Fortran Python Developer Aug 05 '19 at 13:21
  • No, I tried oldest version of compilers. But it's important that for an example test files I used latest compiler version and `successfully` is for the example test . Still now my main question exists. – Fortran Python Developer Aug 06 '19 at 14:14
  • [SOLVED] As I used instruction same as `UPDATE #1` with a little modification , `spherical.py` could execute successfully, with no errors. – Fortran Python Developer Aug 06 '19 at 15:28

1 Answers1

0

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.