Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Windows上的f2py:未定义的引用_Python_Windows_Fortran_F2py - Fatal编程技术网

Python Windows上的f2py:未定义的引用

Python Windows上的f2py:未定义的引用,python,windows,fortran,f2py,Python,Windows,Fortran,F2py,我试图在Windows上用f2py编译一个简单的Hello_World.f90程序,但是得到了很多未定义的引用 第一个错误是: C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.o:在函数“导入数组”中: C:/Users/KB/Python/Python-3.4.4.amd64/lib/site-pack

我试图在Windows上用f2py编译一个简单的Hello_World.f90程序,但是得到了很多未定义的引用

第一个错误是:
C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.o:在函数“导入数组”中:
C:/Users/KB/Python/Python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/\uuuuuuu-multiarray\u-api.h:1466:未定义对`\uimp\upyimport\uimportmodule'的引用。

具有以下几个相同类型的错误

我尝试在
cygwinccompiler.py
(from)中向编译器参数
compiler\u so
添加
-D MS\u WIN64
,但这没有帮助

我怎样才能解决这个问题

部分输出如下所示:

c:\Users\KB\Fortran_Routines>python C:\Users\KB\Python\python-3.4.4.amd64\Scripts\f2py.py -c --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71 -m hello hello.f90 
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "hello" sources
f2py options: []
f2py:> C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.c
creating C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4
Reading fortran codes...
    Reading file 'hello.f90' (format:free)
Post-processing...
    Block: hello
            Block: mod_hello
                Block: hello
Post-processing (stage 2)...
    Block: hello
        Block: unknown_interface
            Block: mod_hello
                Block: hello
Building modules...
    Building module "hello"...
        Constructing F90 module support for "mod_hello"...
            Constructing wrapper function "mod_hello.hello"...
              hello(a)
    Wrote C/API module "hello" to file "C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.c"
    Fortran 90 wrappers are saved to "C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4\hello-f2pywrappers2.f90"
  adding 'C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4\fortranobject.c' to sources.
  adding 'C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4' to include_dirs.
copying C:\Users\KB\Python\python-3.4.4.amd64\lib\site-packages\numpy\f2py\src\fortranobject.c -> C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4
copying C:\Users\KB\Python\python-3.4.4.amd64\lib\site-packages\numpy\f2py\src\fortranobject.h -> C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4
  adding 'C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4\hello-f2pywrappers2.f90' to sources.
build_src: building npy-pkg config files
running build_ext
customize Mingw32CCompiler
customize Mingw32CCompiler using build_ext
customize Gnu95FCompiler
Found executable C:\MinGW\bin\gfortran.exe
customize Gnu95FCompiler using build_ext
building 'hello' extension
compiling C sources
C compiler: gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes

creating C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users
creating C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB
creating C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata
creating C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local
creating C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp
creating C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102
creating C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102\src.win-amd64-3.4
compile options: '-DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x1600 -IC:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4 -IC:\Users\KB\Python\python-3.4.4.amd64\lib\site-packages\numpy\core\include -IC:\Users\KB\Python\python-3.4.4.amd64\include -IC:\Users\KB\Python\python-3.4.4.amd64\include -c'
gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes -DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x1600 -IC:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4 -IC:\Users\KB\Python\python-3.4.4.amd64\lib\site-packages\numpy\core\include -IC:\Users\KB\Python\python-3.4.4.amd64\include -IC:\Users\KB\Python\python-3.4.4.amd64\include -c C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.c -o C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.o
gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes -DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x1600 -IC:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4 -IC:\Users\KB\Python\python-3.4.4.amd64\lib\site-packages\numpy\core\include -IC:\Users\KB\Python\python-3.4.4.amd64\include -IC:\Users\KB\Python\python-3.4.4.amd64\include -c C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4\fortranobject.c -o C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102\src.win-amd64-3.4\fortranobject.o
compiling Fortran 90 module sources
Fortran f77 compiler: C:\MinGW\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -O3 -funroll-loops
Fortran f90 compiler: C:\MinGW\bin\gfortran.exe -Wall -g -fno-second-underscore -O3 -funroll-loops
Fortran fix compiler: C:\MinGW\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -O3 -funroll-loops
compile options: '-IC:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4 -IC:\Users\KB\Python\python-3.4.4.amd64\lib\site-packages\numpy\core\include -IC:\Users\KB\Python\python-3.4.4.amd64\include -IC:\Users\KB\Python\python-3.4.4.amd64\include -c'
extra options: '-JC:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\ -IC:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\'
gfortran.exe:f90: hello.f90
compiling Fortran sources
Fortran f77 compiler: C:\MinGW\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -O3 -funroll-loops
Fortran f90 compiler: C:\MinGW\bin\gfortran.exe -Wall -g -fno-second-underscore -O3 -funroll-loops
Fortran fix compiler: C:\MinGW\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -O3 -funroll-loops
compile options: '-IC:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4 -IC:\Users\KB\Python\python-3.4.4.amd64\lib\site-packages\numpy\core\include -IC:\Users\KB\Python\python-3.4.4.amd64\include -IC:\Users\KB\Python\python-3.4.4.amd64\include -c'
extra options: '-JC:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\ -IC:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\'
gfortran.exe:f90: C:\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4\hello-f2pywrappers2.f90
C:\MinGW\bin\gfortran.exe -Wall -g -Wall -g -shared C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.o C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102\src.win-amd64-3.4\fortranobject.o C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\hello.o C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\Users\KB\AppData\Local\Temp\tmpv4ama102\src.win-amd64-3.4\hello-f2pywrappers2.o -Lc:\mingw\lib\gcc\mingw32\6.3.0 -LC:\Users\KB\Python\python-3.4.4.amd64\libs -LC:\Users\KB\Python\python-3.4.4.amd64\PCbuild\amd64 -lmsvcr71 -lpython34 -lgfortran -o .\hello.pyd
C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.o: In function `import_array':
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1466: undefined reference to `_imp__PyImport_ImportModule'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1470: undefined reference to `_imp__PyExc_ImportError'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1470: undefined reference to `_imp__PyErr_SetString'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1473: undefined reference to `_imp__PyObject_GetAttrString'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1476: undefined reference to `_imp__PyExc_AttributeError'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1476: undefined reference to `_imp__PyErr_SetString'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1481: undefined reference to `_imp__PyCapsule_Type'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1482: undefined reference to `_imp__PyExc_RuntimeError'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1482: undefined reference to `_imp__PyErr_SetString'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1486: undefined reference to `_imp__PyCapsule_GetPointer'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1497: undefined reference to `_imp__PyExc_RuntimeError'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1497: undefined reference to `_imp__PyErr_SetString'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1503: undefined reference to `_imp__PyExc_RuntimeError'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1503: undefined reference to `_imp__PyErr_Format'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1509: undefined reference to `_imp__PyExc_RuntimeError'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1509: undefined reference to `_imp__PyErr_Format'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1521: undefined reference to `_imp__PyExc_RuntimeError'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1521: undefined reference to `_imp__PyErr_Format'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1532: undefined reference to `_imp__PyExc_RuntimeError'
C:/Users/KB/Python/python-3.4.4.amd64/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1532: undefined reference to `_imp__PyErr_Format'
C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.o: In function `try_pyarr_from_int':
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:130: undefined reference to `_imp__PyType_IsSubtype'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:130: undefined reference to `_imp__PyObject_Print'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:130: undefined reference to `_imp__PyLong_FromLong'
C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.o: In function `int_from_pyobj':
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:136: undefined reference to `_imp__PyLong_AsLong'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:139: undefined reference to `_imp__PyNumber_Long'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:141: undefined reference to `_imp__PyLong_AsLong'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:145: undefined reference to `_imp__PyComplex_Type'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:145: undefined reference to `_imp__PyComplex_Type'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:145: undefined reference to `_imp__PyType_IsSubtype'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:146: undefined reference to `_imp__PyObject_GetAttrString'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:149: undefined reference to `_imp__PySequence_Check'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:150: undefined reference to `_imp__PySequence_GetItem'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:152: undefined reference to `_imp__PyErr_Clear'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:157: undefined reference to `_imp__PyErr_Occurred'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:159: undefined reference to `_imp__PyErr_SetString'
C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.o: In function `f2py_rout_hello_mod_hello_hello':
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:197: undefined reference to `_imp___Py_NoneStruct'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:204: undefined reference to `_imp__PyArg_ParseTupleAndKeywords'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:218: undefined reference to `_imp__PyErr_Occurred'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:230: undefined reference to `_imp__Py_BuildValue'
C:\Users\KB\AppData\Local\Temp\tmpv4ama102\Release\users\KB\appdata\local\temp\tmpv4ama102\src.win-amd64-3.4\hellomodule.o: In function `PyInit_hello':
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:315: undefined reference to `_imp__PyModule_Create2'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:319: undefined reference to `_imp__PyType_Type'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:320: undefined reference to `_imp__PyErr_Print'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:320: undefined reference to `_imp__PyExc_ImportError'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:320: undefined reference to `_imp__PyErr_SetString'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:321: undefined reference to `_imp__PyErr_Occurred'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:322: undefined reference to `_imp__PyExc_ImportError'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:322: undefined reference to `_imp__PyErr_SetString'
C:/Users/KB/AppData/Local/Temp/tmpv4ama102/src.win-amd64-3.4/hellomodule.c:323: undefined reference to `_imp__PyModule_GetDict

static PyObject*c:\Users\KB\Fortran\u例程\mod\u hello\u错误
无效,听起来生成过程中存在错误:应该使用文件的basename,而不是全名。运行该工具的命令行是什么?命令行是:
c:\Users\KB\Fortran\u Routines>c:\Users\KB\Python\Python-3.4.4.amd64\Python c:\Users\KB\Python\Python-3.4.4.amd64\Scripts\f2py.py-c--fcompiler=gnu95--compiler=mingw32-lmsvcr71-m c:\Users\KB\Fortran\u Routines\mod\u hello c:\Users\KB\Fortran\Fortran\u Routines\hello.f90绝对路径:
C:\Users\KB\Python\Python-3.4.4.amd64\Python C:\Users\KB\Python\Python-3.4.4.amd64\Scripts\f2py.py-C--fcompiler=gnu95--compiler=mingw32-lmsvcr71-m mod_hello C:\Users\KB\Fortran\u例程\hello.f90
错误保持不变:
C:\Users\KBarfus\Fortran\Fortran\u例程\mod hellomodule.C:19:19:asm'或''.'前面的'.'属性'.'':'toke static PyObject*c:\Users\KBarfus\Fortran\u Routines\mod\u hello\u error
您不能删除此
-m
选项吗?另外,您是否可以将CD刻录到fortran文件所在的目录,然后在没有任何绝对路径的情况下重试?