Configuration forpy on Windows with Intel visual fortran complier

forpy is a library to use Python features in Fortran (“embedding Python in Fortran”) as this Link, configuration of it on Visual Studio, Intel Visual Fortran compiler on Windows 10 follows steps as:

Steps

  1. switch debug to x64 mode if anaconda is x64
  2. tools-settings-Intel Composer XE-Visual Fortran-Compilers-x64
    add “C:\ProgramData\Anaconda3\include” to Includes
    add “C:\ProgramData\Anaconda3\libs” to Libraries
    where “C:\ProgramData\Anaconda3\” is root path of python.exe
  3. project properties-Fortran-Preprocessor-Preprocess Source File Yes(/fpp)
    Linker-Input-Additional Dependencies python36.lib (depends on libs)
  4. If step 2 is skipped, “include” path to Fortran-General-Additional Include Directories and “libs” path to Linker-General-Additional Library Directories

Notice:

If I set PYTHONHOME variable on Windows (my anaconda version 3.6.3) an error like “Fatal Python error: Py_Initialize: unable to load the file system codec ModuleNotFoundError: No module named ‘encodings’ “ will be induced like https://bugs.python.org/issue27054. “intro_to_forpy” works well without PYTHONHOME.

update:

works with PYTHONHOME too. Configure PYTHONHOME to “C:\ProgramData\Anaconda3\” at first then open VS compiler

use errcheck to check ierror and print error messages.

define errcheck if(ierror/=0) then;call err_print;stop;endif

if ierror = -1 and show message about “ImportError: DLL load failed: 找不到指定的模块” when use import_py to import some python module, reinstall this module with pip may solve this problem.