Skip to content

Forpy on Windows

Elias Rabel edited this page Nov 18, 2019 · 3 revisions

Forpy on Windows

Using Visual Studio

To link your project with the Python library follow the instructions in issue #7.

Using Codeblocks + MinGW

Steps for using forpy with the gfortran distribution bundled with Codeblocks

To build:

  1. In Codeblocks: Project -> Build Options -> Linker Settings add python37 (depending on version) to "Link libraries"

  2. In the tab "Search directories" -> Linker add the path to your Python distribution For example when using Miniconda3: C:\Users\username\Miniconda3

You can now build your executable in Codeblocks, however running in Codeblocks will give an error. To run your executable outside of Codeblocks:

  1. When using Miniconda/Anaconda: Activate Python environment: conda activate

  2. Setup MinGW environment vars outside of Codeblocks: Run <path_to_Codeblocks>\MinGW\mingwvars.bat

  3. Set the environment variable PYTHONHOME to the path of your Python distribution. Setting environment variables in Windows: See Python docs

You can now run your executable outside of Codeblocks.

Using matplotlib

When using matplotlib you might get the error could not find or load the Qt platform plugin "windows". To fix this set the environment variable QT_PLUGIN_PATH to <path_to_Python_distribution>\Library\plugins (source)

Common errors

  • could not find pythonXY.dll: activate your conda/virtualenv environment -> conda activate
  • could not find libgcc_s_sjlj-1.dll: the MinGW runtime library could not be found -> see point 2. above
  • If you get the following error message then the Python standard library could not be found: set the PYTHONHOME environment variable to the path of your Python distribution. See point 3. above.
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'