构建导入库libpython27.a时出现f2py错误:找不到指定的文件 [英] f2py error while building import library libpython27.a: cannot find the file specified

查看:672
本文介绍了构建导入库libpython27.a时出现f2py错误:找不到指定的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用f2py编译Fortran代码到共享库中,导入并在Windows 10中使用python。(它在我的Linux分区上工作正常)。我安装了anaconda,并使用 conda安装我安装了numpy,scipy,jupyter和matplotlib,都没有错误。我再次使用anaconda安装Fortran编译器,使用 conda install mingw ,没有任何问题。当我运行

I am trying to compile a fortran code using f2py into a shared library to import and use in python on windows 10. (It works fine on my Linux partition.) I installed anaconda, and using conda install I installed numpy, scipy, jupyter, and matplotlib, all without errors. I again used anaconda to install fortran compilers using conda install mingw without any problems. When I run

python C:\Users\user_name\Anaconda2\Scripts\f2py.py -c --fcompiler=gnu95 --compiler=mingw32 -m foo foo.f

我得到以下输出底部的错误信息):

I get the following output (error message at the bottom):

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 "foo" sources
f2py options: []
f2py:> c:\users\user_name\appdata\local\temp\tmpseovl0\src.win-amd64-2.7\foomodule.c
creating c:\users\user_name\appdata\local\temp\tmpseovl0\src.win-amd64-2.7
Reading fortran codes...
        Reading file 'foo.f' (format:fix,strict)
rmbadname1: Replacing "index" with "index_bn".
rmbadname1: Replacing "index" with "index_bn".
rmbadname1: Replacing "index" with "index_bn".
rmbadname1: Replacing "index" with "index_bn".
rmbadname1: Replacing "index" with "index_bn".
rmbadname1: Replacing "index" with "index_bn".
Post-processing...
        Block: foo
                        Block: calculate
                        Block: delan
                        Block: chg
                        Block: del
                        Block: vext
                        Block: pwm
                        Block: rlg
                        Block: gshell
                        Block: pwmg
                        Block: vhf
                        Block: hf
                        Block: exsfnd
                        Block: exscal
                        Block: exs
                        Block: ch
                        Block: factor
                        Block: engan
                        Block: tred3
                        Block: bisect
                        Block: tinvit
                        Block: trbak3
Post-processing (stage 2)...
Building modules...
        Building module "foo"...
                Constructing wrapper function "calculate"...
                  rhor,rhoi,delr,deli,spenergy,xcenergy,intenergy,totenergy = calculate(nsh,memsh,ivec,gmags,vextr,vexti,vmagsr,vmagsi,np,nq,nlan,ifill,e2byal,spenergyfn,[js,jt,eps,nx,nkx,niter,alf,logfn])
                Constructing wrapper function "delan"...
                  delan(delr,deli,nsh,memsh,nlan)
                Constructing wrapper function "chg"...
                  chg(nlan,delr,deli,rhor,rhoi,nsh,memsh,ivec,q0,js,jt,eps)
                Constructing wrapper function "del"...
                  del(q0,nsh,vmagsr,vmagsi,memsh,nq,np,ivec,js,jt,eps,nj,nlan,nkx,nx,delr,deli,ifill,e2byal,delrsv,delisv)
                Constructing wrapper function "vext"...
                  vext(q0,nsh,vmagsr,vmagsi,memsh,nq,np,ivec,js,jt,eps,nj,nlan,hr,hi,rkx,x)
                Constructing wrapper function "pwm"...
                  pwm(np,n,qx,qy,f)
                Creating wrapper for Fortran function "rlg"("rlg")...
                Constructing wrapper function "rlg"...
                  rlg = rlg(alf,x,n)
                Constructing wrapper function "gshell"...
                  ish,nsh,ivec,gmags = gshell(js,jt,eps,gmax)
                Constructing wrapper function "pwmg"...
                  pwmg(n,m,qx,qy,f)
                Constructing wrapper function "vhf"...
                  vhf(q0,nsh,e2byal,memsh,nq,np,ivec,js,jt,eps,nj,nlan,hr,hi,xcr,xci,rkx,x,delr,deli)
                Constructing wrapper function "hf"...
                  hf(delr,deli,im,ish,n1,n2,gx,gy,hxr,hxi,xr,xi,nlan)
                Constructing wrapper function "exsfnd"...
                  exsfnd(n1,m1,n2,m2,ish,exsval,nlan)
                Constructing wrapper function "exscal"...
                  exscal(nlan,gmags,nsh)
                Constructing wrapper function "exs"...
                  exs(ip1,ip2,ip3,ip4,l,gmag,exsval)
                Creating wrapper for Fortran function "ch"("ch")...
                Constructing wrapper function "ch"...
                  ch = ch(a,b,x)
                Creating wrapper for Fortran function "factor"("factor")...
                Constructing wrapper function "factor"...
                  factor = factor(k)
                Constructing wrapper function "engan"...
                  engan(q0,nsh,vmagsr,vmagsi,memsh,nq,np,ivec,js,jt,eps,nj,nlan,nkx,nx,delr,deli,ifill,e2byal,esp,exc,eint,etot,energyfn)
                Constructing wrapper function "tred3"...
                  tred3(ar,ai,d,e,e2,tau,[n,nv])
                Constructing wrapper function "bisect"...
                  bisect(eps1,d,e,e2,lb,ub,m,w,ind,ierr,rv4,rv5,[n,mm])
                Constructing wrapper function "tinvit"...
                  tinvit(d,e,e2,w,ind,z,ierr,rv1,rv2,rv3,rv4,rv6,[nm,n,m])
                Constructing wrapper function "trbak3"...
                  trbak3(ar,ai,tau,zr,zi,[nm,n,nv,m])
                Constructing COMMON block support for "exspas"...
                  exssto,nsto,nvlan
        Wrote C/API module "foo" to file "c:\users\user_name\appdata\local\temp\tmpseovl0\src.win-amd64-2.7\foomodule.c"
        Fortran 77 wrappers are saved to "c:\users\user_name\appdata\local\temp\tmpseovl0\src.win-amd64-2.7\foo-f2pywrappers.f"
  adding 'c:\users\user_name\appdata\local\temp\tmpseovl0\src.win-amd64-2.7\fortranobject.c' to sources.
  adding 'c:\users\user_name\appdata\local\temp\tmpseovl0\src.win-amd64-2.7' to include_dirs.
copying C:\Users\user_name\Anaconda2\lib\site-packages\numpy\f2py\src\fortranobject.c -> c:\users\user_name\appdata\local\temp\tmpseovl0\src.win-amd64-2.7
copying C:\Users\user_name\Anaconda2\lib\site-packages\numpy\f2py\src\fortranobject.h -> c:\users\user_name\appdata\local\temp\tmpseovl0\src.win-amd64-2.7
  adding 'c:\users\user_name\appdata\local\temp\tmpseovl0\src.win-amd64-2.7\foo-f2pywrappers.f' to sources.
build_src: building npy-pkg config files
running build_ext
Looking for python27.dll
Building import library (arch=AMD64): "C:\Users\user_name\Anaconda2\libs\libpython27.a" (from C:\Users\user_name\Anaconda2\python27.dll)
error: [Error 2] The system cannot find the file specified

我可能会离开基地,但在我看来,编译进行得很顺利,试图组装一个python模块。存在 C:\ Users \ user_name\Anaconda2\python27.dll 文件。文件 C:\ Users \ user_name\Anaconda2\libs\libpython27.a 不存在。我检查了我能够在文件夹中创建文件( C:\ Users \ user_name\Anconda2\libs\ )。

I could be way off-base, but it looks to me like the compilation goes well, and the error occurs when trying to put together a python module. The file C:\Users\user_name\Anaconda2\python27.dll exists. The file C:\Users\user_name\Anaconda2\libs\libpython27.a does not exist. I checked that I was able to create files in the folder (C:\Users\user_name\Anaconda2\libs\).

推荐答案

刚才我有类似的设置(虽然使用Windows 7)也有同样的问题。一段时间后,我发现安装libpython包( conda install libpython )似乎解决了这个问题。

I had this same problem just now with a similar setup (though using Windows 7). After awhile, I found that installing the libpython package (conda install libpython) seemed to fix it.

我想使用描述 gendef / dlltool 6950787> 在这里也可以做到这一点。

I think using the gendef / dlltool approach described here would also do the trick.

这篇关于构建导入库libpython27.a时出现f2py错误:找不到指定的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆