Setting python path for WinPython to use f2py
Question: I installed the Winpython distribution on my copy of Windows 7. Launching
iPython consoles and other items from the distribution from within the folder
it copied to works fine.

I'd like to use the f2py module from numpy to be able to call Fortran
subroutines from Python. My understanding is that f2py must be called from the
command line, but the system does not seem to find f2py, returning
`ImportError: no module named site` when I call it either with or without
flags. This same error is returned when I try to run python itself from the
command line.

When I manually navigate to the Winpython directory (e.g.
`C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5`) and call `f2py -c --help-
fcompiler` to see if f2py is found there, I receive the following error

    
    
    Traceback (most recent call last):
      File ".\lib\site.py", line 538, in main
        main()
      File ".\lib\site.py", line 530, in main
        known_paths = addusersitepackages(known_paths)
      File ".\lib\site.py", line 266, in addusersitepackages
        user_site = getusersitepackages()
      File ".\lib\site.py", line 241, in getusersitepackages
        user_base = getuserbase() # this will also set USER_BASE
      File ".\lib\site.py", line 231, in getuserbase
        USER_BASE = get_config_var('userbase')
      File "C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5\lib\sysconfig.py",
     line 516, in get_config_var
        return get_config_vars().get(name)
      File "C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5\lib\sysconfig.py",
     line 449, in get_config_vars
        import re
      File "C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5\lib\re.py", line 1
    05, in <module>
        import sre_compile
      File "C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5\lib\sre_parse.py"
    ", line 14, in <module>
        import sre_parse
      File "C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5\lib\sre_constants.py",
     line 17, in <module>
        from sre_constants import *
      File "C:\Users\konings\WinPython-32bit-2.7.5.3\pyt
    py", line 18, in <module>
        from _sre import MAXREPEAT
    ImportError: cannot import name MAXREPEAT
    

Could somebody explain to me what this error means and/or how to use f2py with
Winpython? Thanks!


Answer: You can set your environment variable `PYTHONPATH` pointing to the folder
where these modules are. This should solve the `ImportError`s.

