Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
F2PY.......plz!!!!
#11
Sorry!!! And thx for your help
I installed numpy+mkl, gnu95, VC++ for Python27, and upgrated setuptools to up-to-date correctly.
when I put [Python -m numpy.f2py -c -fcompiler=gnu95 -m prime primepy.f90] into cmd, [compiling C sources error: Unable to find vcvarsall.bat] was came out.

C:\Users\Owner>Python -m numpy.f2py -c -fcompiler=gnu95 -m prime primepy.f90

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 "prime" sources
f2py options: []
f2py:> c:\users\owner\appdata\local\temp\tmpmqpsn2\src.win32-2.7\primemodule.c
creating c:\users\owner\appdata\local\temp\tmpmqpsn2\src.win32-2.7
Reading fortran codes...
        Reading file 'primepy.f90' (format:fix)
Post-processing...
        Block: prime
                        Block: prime_number
Post-processing (stage 2)...
Building modules...
        Building module "prime"...
                Constructing wrapper function "prime_number"...
                  ret = prime_number(max_num)
        Wrote C/API module "prime" to file "c:\users\owner\appdata\local\temp\tm
pmqpsn2\src.win32-2.7\primemodule.c"
  adding 'c:\users\owner\appdata\local\temp\tmpmqpsn2\src.win32-2.7\fortranobjec
t.c' to sources.
  adding 'c:\users\owner\appdata\local\temp\tmpmqpsn2\src.win32-2.7' to include_
dirs.
copying c:\Python27\lib\site-packages\numpy\f2py\src\fortranobject.c -> c:\users
\owner\appdata\local\temp\tmpmqpsn2\src.win32-2.7
copying c:\Python27\lib\site-packages\numpy\f2py\src\fortranobject.h -> c:\users
\owner\appdata\local\temp\tmpmqpsn2\src.win32-2.7
build_src: building npy-pkg config files
running build_ext
customize MSVCCompiler
customize MSVCCompiler 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:\Users\Owner\gfortran\bin\gfortran.exe
Found executable C:\Users\Owner\gfortran\bin\gfortran.exe
customize Gnu95FCompiler
customize Gnu95FCompiler using build_ext
building 'prime' extension
compiling C sources
error: Unable to find vcvarsall.bat

it might be problem that when I search [where vcvarsall.bat], it said there is no such file.
Reply
#12
Disclaimer: I'm working from memory and I'm making a few assumptions. I've given up using Microsoft's compilers. :(

vcvarsall.bat is included with the now obsolete Visual Studio 2008 suite. It configures your system for the particular compiler (32-bit vs. 64-bit) that you are trying to use. The VC++ for Python 2.7 probably does not include it. I found some documentation I wrote several years ago for compiling with the Windows 7 SDK compilers which is roughly comparable (I think) to VC++ for Python 2.7. Instead of a single batch file that is run automatically by the build process, you need to find and run "vcvars64.bat" or "vcvars32.bat" to configure your system for either a 64-bit or 32-bit compiler. Do this before trying to compile your module. It might get you further.

I maintain the gmpy2 library and I am migrating to the MSYS2 environment and the mingw64 compilers. I haven't tried it with f2py but it may be an option for you.

Another option that might work is called "mingwpy". It was actively developed by the numpy community for a while, but development seems to have stopped.

Unfortunately, the best way to compile C or Fortran libraries for Python is to install Linux in a virtual machine.
Reply
#13
Regarding:
error: Unable to find vcvarsall.bat
I have many times in the past needed to do crap like this on windows:
SET VS90COMNTOOLS=%VS100COMNTOOLS%
Stack thread
http://stackoverflow.com/a/10558328
Reply
#14
(Oct-07-2016, 03:35 AM)Mekire Wrote: Regarding:
error: Unable to find vcvarsall.bat
I have many times in the past needed to do crap like this on windows:
SET VS90COMNTOOLS=%VS100COMNTOOLS%
Stack thread
http://stackoverflow.com/a/10558328

That command has the side-effect of convincing Python to use a different version of Visual Studio than was used to compile Python itself. The compiled module will use a different version of the C runtime library than Python. It will frequently work, or appear to work, but there are always some incompatibilities between the different runtime libraries. IIRC, some error handling is different, file I/O is different, and memory management is different. As long as you avoid the differences, it will work. But the differences aren't documented....
Reply
#15
Oh, I agree.  It is a terrible solution, but I have had success with it when nothing else will work.

As I said though, this was in the past; I haven't had to do this recently that I remember.
I would hope that it is no longer necessary in most situations.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  f2py: no Fortran compiler found FMJS 2 5,337 May-25-2020, 02:51 PM
Last Post: FMJS
  f2py recovering variables from Fortran module marius 0 3,411 Dec-02-2016, 03:52 PM
Last Post: marius
  Question about F2py...Help me plz!!! Yuji3131 3 8,943 Oct-05-2016, 09:59 AM
Last Post: Yuji3131

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020