2016-07-19 5 views
0

Ich versuche, einen Fortran-Code mit f2py in eine gemeinsame Bibliothek zu importieren und in Python auf Windows 10 zu verwenden. (Es funktioniert gut auf meiner Linux-Partition .) Ich habe Anaconda installiert und mit conda install habe ich numpy, scipy, jupyter und matplotlib installiert, alles ohne Fehler. Ich benutzte Anaconda wieder, um Fortran-Compiler mit conda install mingw ohne Probleme zu installieren. Als ichf2py Fehler beim Erstellen Import-Bibliothek libpython27.a: kann die angegebene Datei nicht finden

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

laufen bekomme ich folgende Ausgabe (Fehlermeldung am unteren Rand):

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 

I Weg off-base sein könnte, aber es scheint mir, wie die Zusammenstellung gut geht, und Der Fehler tritt auf, wenn ein Python-Modul zusammengestellt werden soll. Die Datei C:\Users\user_name\Anaconda2\python27.dll existiert. Die Datei C:\Users\user_name\Anaconda2\libs\libpython27.a existiert nicht. Ich habe überprüft, dass ich Dateien im Ordner erstellen konnte (C:\Users\user_name\Anaconda2\libs\).

Antwort

0

Ich hatte das gleiche Problem gerade jetzt mit einem ähnlichen Setup (obwohl mit Windows 7). Nach einiger Zeit stellte ich fest, dass die Installation des libpython-Pakets (conda install libpython) das Problem zu beheben schien.

Ich denke, mit der gendef/dlltool Ansatz beschrieben here würde auch den Trick tun.

Verwandte Themen