Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

f2py can't creat .pyd file #26277

Closed
Ying-Zi66 opened this issue Apr 14, 2024 · 2 comments
Closed

f2py can't creat .pyd file #26277

Ying-Zi66 opened this issue Apr 14, 2024 · 2 comments
Labels
57 - Close? Issues which may be closable unless discussion continued component: numpy.f2py

Comments

@Ying-Zi66
Copy link

Ying-Zi66 commented Apr 14, 2024

I use f2py to create a python module.But it dosen't works. I use intel onapi and ifort.
This is my fortran code(test_add.f90):

subroutine  myadd(a,b,c) 
   implicit none
   real*8 ::a,b,c
   c = a + b
end subroutine 

ifort works in my pc:
(base) PS C:\Users\yingzi\Documents\pythonfile\f2py_learn> ifort
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.12.0 Build 20240222_000000
Copyright (C) 1985-2024 Intel Corporation. All rights reserved.
ifort: remark #10448: Intel(R) Fortran Compiler Classic (ifort) is now deprecated and will be discontinued late 2024. Intel recommends that customers transition now to using the LLVM-based Intel(R) Fortran Compiler (ifx) for continued Windows* and Linux* support, new language support, new language features, and optimizations. Use '/Qdiag-disable:10448' to disable this message.
ifort: command line error: no files specified; for help type "ifort /help"

 (base) PS C:\Users\yingzi\Documents\pythonfile\f2py_learn> f2py -c test_add.f90 -m testadd
`C:\Users\yingzi\AppData\Roaming\Python\Python310\site-packages\numpy\f2py\f2py2e.py:719: VisibleDeprecationWarning: distutils has been deprecated since NumPy 1.26.xUse the Meson backend instead, or generate wrapperswithout -c and use a custom build script
  builder = build_backend(
running build
running config_cc
INFO: unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
INFO: unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
INFO: build_src
INFO: building extension "testadd" sources
INFO: f2py options: []
INFO: f2py:> C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10\testaddmodule.c
creating C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10
Reading fortran codes...
        Reading file 'test_add.f90' (format:free)
Post-processing...
        Block: testadd
                        Block: myadd
Applying post-processing hooks...
  character_backward_compatibility_hook
Post-processing (stage 2)...
Building modules...
    Building module "testadd"...
    Generating possibly empty wrappers"
    Maybe empty "testadd-f2pywrappers.f"
        Constructing wrapper function "myadd"...
          myadd(a,b,c)
    Wrote C/API module "testadd" to file "C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10\testaddmodule.c"
INFO:   adding 'C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10\fortranobject.c' to sources.
INFO:   adding 'C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10' to include_dirs.
copying C:\Users\yingzi\AppData\Roaming\Python\Python310\site-packages\numpy\f2py\src\fortranobject.c -> C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10
copying C:\Users\yingzi\AppData\Roaming\Python\Python310\site-packages\numpy\f2py\src\fortranobject.h -> C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10
INFO:   adding 'C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10\testadd-f2pywrappers.f' to sources.
INFO: build_src: building npy-pkg config files
C:\ProgramData\anaconda3\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
running build_ext
INFO: No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
INFO: customize MSVCCompiler
INFO: customize MSVCCompiler using build_ext
INFO: get_default_fcompiler: matching types: '['gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 'intelem', 'flang']'
INFO: customize GnuFCompiler
WARN: Could not locate executable g77
WARN: Could not locate executable f77
INFO: customize IntelVisualFCompiler
INFO: Found executable C:\Program Files (x86)\Intel\oneAPI\compiler\latest\bin\ifort.exe
WARN: Could not locate executable C:\Program
INFO: customize AbsoftFCompiler
WARN: Could not locate executable f90
INFO: customize CompaqVisualFCompiler
WARN: Could not locate executable DF
INFO: customize IntelItaniumVisualFCompiler
WARN: Could not locate executable efl
INFO: customize Gnu95FCompiler
WARN: Could not locate executable gfortran
WARN: Could not locate executable f95
INFO: customize G95FCompiler
WARN: Could not locate executable g95
INFO: customize IntelEM64VisualFCompiler
INFO: customize IntelEM64VisualFCompiler
INFO: customize IntelEM64VisualFCompiler using build_ext
INFO: building 'testadd' extension
INFO: compiling C sources
creating C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\Release\Users
creating C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\Release\Users\yingzi
creating C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\Release\Users\yingzi\AppData
creating C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\Release\Users\yingzi\AppData\Local
creating C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\Release\Users\yingzi\AppData\Local\Temp
creating C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\Release\Users\yingzi\AppData\Local\Temp\tmpf837pzn_
creating C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\Release\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10
INFO: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\HostX86\x64\cl.exe /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DNPY_DISABLE_OPTIMIZATION=1 -IC:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10 -IC:\Users\yingzi\AppData\Roaming\Python\Python310\site-packages\numpy\core\include -IC:\ProgramData\anaconda3\include -IC:\ProgramData\anaconda3\Include -IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include -IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\ATLMFC\include -IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um -IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared -IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt -IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt /TcC:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10\testaddmodule.c /FoC:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\Release\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10\testaddmodule.obj
INFO: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\HostX86\x64\cl.exe /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DNPY_DISABLE_OPTIMIZATION=1 -IC:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10 -IC:\Users\yingzi\AppData\Roaming\Python\Python310\site-packages\numpy\core\include -IC:\ProgramData\anaconda3\include -IC:\ProgramData\anaconda3\Include -IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include -IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\ATLMFC\include -IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um -IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared -IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt -IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt /TcC:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10\fortranobject.c /FoC:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\Release\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10\fortranobject.obj
INFO: compiling Fortran sources
INFO: Fortran f77 compiler: C:\Program Files (x86)\Intel\oneAPI\compiler\latest\bin\ifort.exe Files (x86)\Intel\oneAPI\compiler\latest\bin\ifort.exe /nologo /MD /nbs /names:lowercase /assume:underscore /fpp /O1 /assume:minus0
Fortran f90 compiler: C:\Program Files (x86)\Intel\oneAPI\compiler\latest\bin\ifort.exe Files (x86)\Intel\oneAPI\compiler\latest\bin\ifort.exe /nologo /MD /nbs /names:lowercase /assume:underscore /fpp /O1 /assume:minus0
Fortran fix compiler: C:\Program Files (x86)\Intel\oneAPI\compiler\latest\bin\ifort.exe Files (x86)\Intel\oneAPI\compiler\latest\bin\ifort.exe /nologo /MD /nbs /names:lowercase /assume:underscore /fpp /O1 /assume:minus0
INFO: compile options: '-IC:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10 -IC:\Users\yingzi\AppData\Roaming\Python\Python310\site-packages\numpy\core\include -IC:\ProgramData\anaconda3\include -IC:\ProgramData\anaconda3\Include -c'
INFO: ifort.exe:f90: test_add.f90
ifort: remark #10448: Intel(R) Fortran Compiler Classic (ifort) is now deprecated and will be discontinued late 2024. Intel recommends that customers transition now to using the LLVM-based Intel(R) Fortran Compiler (ifx) for continued Windows* and Linux* support, new language support, new language features, and optimizations. Use '/Qdiag-disable:10448' to disable this message.
ifort: command line warning #10161: unrecognized source type 'Files'; object file assumed
ifort: command line warning #10161: unrecognized source type '(x86)\Intel\oneAPI\compiler\latest\bin\ifort.exe'; object file assumed
ifort: command line warning #10006: ignoring unknown option '/c '
ifort: warning #10145: no action performed for file 'Files'
ifort: warning #10145: no action performed for file '(x86)\Intel\oneAPI\compiler\latest\bin\ifort.exe'
INFO: ifort.exe:f77: C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10\testadd-f2pywrappers.f
ifort: remark #10448: Intel(R) Fortran Compiler Classic (ifort) is now deprecated and will be discontinued late 2024. Intel recommends that customers transition now to using the LLVM-based Intel(R) Fortran Compiler (ifx) for continued Windows* and Linux* support, new language support, new language features, and optimizations. Use '/Qdiag-disable:10448' to disable this message.
ifort: command line warning #10161: unrecognized source type 'Files'; object file assumed
ifort: command line warning #10161: unrecognized source type '(x86)\Intel\oneAPI\compiler\latest\bin\ifort.exe'; object file assumed
ifort: command line warning #10006: ignoring unknown option '/c '
ifort: warning #10145: no action performed for file 'Files'
ifort: warning #10145: no action performed for file '(x86)\Intel\oneAPI\compiler\latest\bin\ifort.exe'
INFO: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\ProgramData\anaconda3\libs /LIBPATH:C:\ProgramData\anaconda3 /LIBPATH:C:\ProgramData\anaconda3\PCbuild\amd64 /LIBPATH:C:\ProgramData\anaconda3\libs /LIBPATH:C:\ProgramData\anaconda3 /LIBPATH:C:\ProgramData\anaconda3\PCbuild\amd64 /LIBPATH:C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\ATLMFC\lib\x64 /LIBPATH:C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\lib\x64 /LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\ucrt\x64 /LIBPATH:C:\Program Files (x86)\Windows Kits\10\\lib\10.0.22621.0\\um\x64 /EXPORT:PyInit_testadd C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\Release\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10\testaddmodule.obj C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\Release\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10\fortranobject.obj C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\Release\test_add.o C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\Release\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10\testadd-f2pywrappers.o /OUT:.\testadd.cp310-win_amd64.pyd /IMPLIB:C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\Release\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10\testadd.cp310-win_amd64.lib
LINK : fatal error LNK1104: �޷����ļ���ifconsol.lib��
error: Command "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\ProgramData\anaconda3\libs /LIBPATH:C:\ProgramData\anaconda3 /LIBPATH:C:\ProgramData\anaconda3\PCbuild\amd64 /LIBPATH:C:\ProgramData\anaconda3\libs /LIBPATH:C:\ProgramData\anaconda3 /LIBPATH:C:\ProgramData\anaconda3\PCbuild\amd64 /LIBPATH:C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\ATLMFC\lib\x64 /LIBPATH:C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\lib\x64 /LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\ucrt\x64 /LIBPATH:C:\Program Files (x86)\Windows Kits\10\\lib\10.0.22621.0\\um\x64 /EXPORT:PyInit_testadd C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\Release\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10\testaddmodule.obj C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\Release\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10\fortranobject.obj C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\Release\test_add.o C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\Release\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10\testadd-f2pywrappers.o /OUT:.\testadd.cp310-win_amd64.pyd /IMPLIB:C:\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\Release\Users\yingzi\AppData\Local\Temp\tmpf837pzn_\src.win-amd64-3.10\testadd.cp310-win_amd64.lib" failed with exit status 1104`
@mattip
Copy link
Member

mattip commented Apr 14, 2024

Apparently, as you can see in your output, ifort is deprecated and you should be using the clang-based ifx instead.

You are getting a link error 1104 which as far as I can tell means the file ifconsol.lib cannot be found. Does it exist somewhere?

Neither of these problems are NumPy specific.

@HaoZeke
Copy link
Member

HaoZeke commented Apr 28, 2024

Also please try with a newer NumPy and/or pass --backend meson

@HaoZeke HaoZeke added component: numpy.f2py 57 - Close? Issues which may be closable unless discussion continued labels Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
57 - Close? Issues which may be closable unless discussion continued component: numpy.f2py
Projects
None yet
Development

No branches or pull requests

3 participants