Re: [f2py] Import error .pyd module
[email protected] Mon, 18 Feb 2013 15:38:15 +0100
| Newsgroups | gmane.comp.python.f2py.user |
|---|---|
| Message-ID | <[email protected]> |
Hi again, problem solved: python did not know the path of hello.pyd. I had to place it in python's folder DLLs, now it works :) best regards Mara -------- Original-Nachricht -------- > Datum: Sun, 17 Feb 2013 19:08:18 +0100 > Von: [email protected] > An: f2py-users-Y4l6ocDipWCuvFJfX82//[email protected] > Betreff: [f2py] Import error .pyd module > Hi, > > I try to use f2py for the first time. > f2py.py is located under C:\Python33\Scripts. > I'm using gfortran, so I added a file distutils.cfg including the 2 lines > > [build] > compiler = mingw32 > > to the directory C:\Python33\Lib\distutils. > > The Fortran code hello.f is located under > C:\Users\Mara\Desktop\PythonDoku\FortranCode and reads: > > C File hello.f > subroutine foo (a) > integer a > print*, "Hello from Fortran!" > print*, "a=",a > end > > I apply f2py as follows to this Fortran code: > > C:\Users\Mara\Desktop\PythonDoku\FortranCode>python > C:\Python33\Scripts\f2py.py > -c -m hello hello.f > > This indeed produces a file hello.pyd in the folder FortranCode. For > completeness here the output of the shell: > > running build > running config_cc > unifing config_cc, config, build_clib, build_ext, build commands > --compiler opti > ons > running config_fc > unifing config_fc, config, build_clib, build_ext, build commands > --fcompiler opt > ions > running build_src > build_src > building extension "hello" sources > f2py options: [] > f2py:> > c:\users\mara\appdata\local\temp\tmp7bzbwm\src.win32-3.3\hellomodule.c > creating c:\users\mara\appdata\local\temp\tmp7bzbwm > creating c:\users\mara\appdata\local\temp\tmp7bzbwm\src.win32-3.3 > Reading fortran codes... > Reading file 'hello.f' (format:fix,strict) > Post-processing... > Block: hello > Block: foo > Post-processing (stage 2)... > Building modules... > Building module "hello"... > Constructing wrapper function "foo"... > foo(a) > Wrote C/API module "hello" to file > "c:\users\mara\appdata\local\temp\tmp > 7bzbwm\src.win32-3.3\hellomodule.c" > adding > 'c:\users\mara\appdata\local\temp\tmp7bzbwm\src.win32-3.3\fortranobject > .c' to sources. > adding 'c:\users\mara\appdata\local\temp\tmp7bzbwm\src.win32-3.3' to > include_d > irs. > copying C:\Python33\lib\site-packages\numpy\f2py\src\fortranobject.c -> > c:\users > \mara\appdata\local\temp\tmp7bzbwm\src.win32-3.3 > copying C:\Python33\lib\site-packages\numpy\f2py\src\fortranobject.h -> > c:\users > \mara\appdata\local\temp\tmp7bzbwm\src.win32-3.3 > build_src: building npy-pkg config files > running build_ext > Cannot build msvcr library: "msvcr100d.dll" not found > customize Mingw32CCompiler > customize Mingw32CCompiler using build_ext > customize GnuFCompiler > Could not locate executable g77 > Could not locate executable f77 > customize IntelVisualFCompiler > Could not locate executable ifort > Could not locate executable ifl > customize AbsoftFCompiler > Could not locate executable f90 > customize CompaqVisualFCompiler > Could not locate executable DF > customize IntelItaniumVisualFCompiler > Could not locate executable efl > customize Gnu95FCompiler > Found executable C:\MinGW\bin\gfortran.exe > Found executable C:\MinGW\bin\gfortran.exe > customize Gnu95FCompiler > customize Gnu95FCompiler using build_ext > building 'hello' extension > compiling C sources > C compiler: gcc -O2 -Wall -Wstrict-prototypes > > creating c:\users\mara\appdata\local\temp\tmp7bzbwm\Release > creating c:\users\mara\appdata\local\temp\tmp7bzbwm\Release\users > creating c:\users\mara\appdata\local\temp\tmp7bzbwm\Release\users\mara > creating > c:\users\mara\appdata\local\temp\tmp7bzbwm\Release\users\mara\appdata > creating > c:\users\mara\appdata\local\temp\tmp7bzbwm\Release\users\mara\appdata\l > ocal > creating > c:\users\mara\appdata\local\temp\tmp7bzbwm\Release\users\mara\appdata\l > ocal\temp > creating > c:\users\mara\appdata\local\temp\tmp7bzbwm\Release\users\mara\appdata\l > ocal\temp\tmp7bzbwm > creating > c:\users\mara\appdata\local\temp\tmp7bzbwm\Release\users\mara\appdata\l > ocal\temp\tmp7bzbwm\src.win32-3.3 > compile options: '-DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x1000 > -Ic:\ > users\mara\appdata\local\temp\tmp7bzbwm\src.win32-3.3 > -IC:\Python33\lib\site-pac > kages\numpy\core\include -IC:\Python33\include -IC:\Python33\include -c' > gcc -O2 -Wall -Wstrict-prototypes -DNPY_MINGW_USE_CUSTOM_MSVCR > -D__MSVCRT_VERSIO > N__=0x1000 -Ic:\users\mara\appdata\local\temp\tmp7bzbwm\src.win32-3.3 > -IC:\Pytho > n33\lib\site-packages\numpy\core\include -IC:\Python33\include > -IC:\Python33\inc > lude -c > c:\users\mara\appdata\local\temp\tmp7bzbwm\src.win32-3.3\fortranobject.c > -o > c:\users\mara\appdata\local\temp\tmp7bzbwm\Release\users\mara\appdata\local\ > temp\tmp7bzbwm\src.win32-3.3\fortranobject.o > Found executable C:\MinGW\bin\gcc.exe > gcc -O2 -Wall -Wstrict-prototypes -DNPY_MINGW_USE_CUSTOM_MSVCR > -D__MSVCRT_VERSIO > N__=0x1000 -Ic:\users\mara\appdata\local\temp\tmp7bzbwm\src.win32-3.3 > -IC:\Pytho > n33\lib\site-packages\numpy\core\include -IC:\Python33\include > -IC:\Python33\inc > lude -c > c:\users\mara\appdata\local\temp\tmp7bzbwm\src.win32-3.3\hellomodule.c - > o > c:\users\mara\appdata\local\temp\tmp7bzbwm\Release\users\mara\appdata\local\te > mp\tmp7bzbwm\src.win32-3.3\hellomodule.o > compiling Fortran sources > Fortran f77 compiler: C:\MinGW\bin\gfortran.exe -Wall -ffixed-form > -fno-second-u > nderscore -O3 -funroll-loops > Fortran f90 compiler: C:\MinGW\bin\gfortran.exe -Wall > -fno-second-underscore -O3 > -funroll-loops > Fortran fix compiler: C:\MinGW\bin\gfortran.exe -Wall -ffixed-form > -fno-second-u > nderscore -Wall -fno-second-underscore -O3 -funroll-loops > compile options: > '-Ic:\users\mara\appdata\local\temp\tmp7bzbwm\src.win32-3.3 -IC > :\Python33\lib\site-packages\numpy\core\include -IC:\Python33\include > -IC:\Pytho > n33\include -c' > gfortran.exe:f77: hello.f > C:\MinGW\bin\gfortran.exe -Wall -Wall -shared > c:\users\mara\appdata\local\temp\t > mp7bzbwm\Release\users\mara\appdata\local\temp\tmp7bzbwm\src.win32-3.3\hellomodu > le.o > c:\users\mara\appdata\local\temp\tmp7bzbwm\Release\users\mara\appdata\local > \temp\tmp7bzbwm\src.win32-3.3\fortranobject.o > c:\users\mara\appdata\local\temp\t > mp7bzbwm\Release\hello.o -Lc:\mingw\lib\gcc\mingw32\4.5.2 > -LC:\Python33\libs -LC > :\Python33\PCbuild -lpython33 -lgfortran -o .\hello.pyd > running scons > Removing build directory c:\users\mara\appdata\local\temp\tmp7bzbwm > > > > However, when I try to hello.pyd in the python shell, I obtain the > following error: > > >>> import hello > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > ImportError: No module named 'hello' > > I would be glad for any help! Thank you in advance, > Mara > > > _______________________________________________ > f2py-users mailing list > f2py-users-Y4l6ocDipWCuvFJfX82//[email protected] > http://cens.ioc.ee/mailman/listinfo/f2py-users