forpy icon indicating copy to clipboard operation
forpy copied to clipboard

Matplotlib Example Fails

Open OrbitalMechanic opened this issue 6 years ago • 3 comments

I'm attempting to run the Matplotlib Example using forpy installed on an iMacPro running Mac OS X Mojave (ver. 10.14.5) under the Anaconda distribution for Python 3.7.

Building the example (see the attached file Example1.F90.txt) was successful, but running a.out results with:

(base) Samuels-Mac-Pro:Matplotlib_example user$ touch *.F90 (base) Samuels-Mac-Pro:Matplotlib_example user$ gfortran -c forpy_mod.F90 (base) Samuels-Mac-Pro:Matplotlib_example user$ gfortran Example1.F90 forpy_mod.o python3-config --ldflags (base) Samuels-Mac-Pro:Matplotlib_example user$ ./a.out Could not find platform independent libraries Could not find platform dependent libraries <exec_prefix> Consider setting $PYTHONHOME to [:<exec_prefix>] Fatal Python error: initfsencoding: unable to load the file system codec ModuleNotFoundError: No module named 'encodings'

Current thread 0x00000001099ea5c0 (most recent call first):

Program received signal SIGABRT: Process abort signal.

Backtrace for this error: #0 0x106edb39d #1 0x106eda82b #2 0x7fff59843b5c Abort trap: 6 (base) Samuels-Mac-Pro:Matplotlib_example user$

Any suggestions?

Example1.F90.txt

OrbitalMechanic avatar Jul 10 '19 03:07 OrbitalMechanic

Hi, I'd guess it might be something along the lines as described in https://github.com/SpaceVim/SpaceVim/issues/1296 (see also the links in there). Unfortunately I don't have access to a Mac and can't try to reproduce the issue.

You can check the paths where Python looks for modules using this code:

program paths
  use forpy_mod
  implicit none

  integer :: ierror
  type(list) :: paths

  ierror = forpy_initialize()
  ierror = get_sys_path(paths)
  ierror = print_py(paths)

end program

ylikx avatar Jul 10 '19 21:07 ylikx

Hi, I'd guess it might be something along the lines as described in SpaceVim/SpaceVim#1296 (see also the links in there). Unfortunately I don't have access to a Mac and can't try to reproduce the issue.

You can check the paths where Python looks for modules using this code:

program paths
  use forpy_mod
  implicit none

  integer :: ierror
  type(list) :: paths

  ierror = forpy_initialize()
  ierror = get_sys_path(paths)
  ierror = print_py(paths)

end program

I try this example on windows, and also it only works when put the compiled executable in the path where python.exe located, in my case, "C:\IntelSWTools\intelpython3", it seems that the compiled executable only tries to find python libs in current path.

econwang avatar Jul 11 '19 13:07 econwang

This should be fixed by setting the PYTHONHOME environment variable.

On Windows: https://docs.python.org/3.7/using/windows.html#configuring-python https://docs.python.org/3.7/using/windows.html#finding-modules

On Mac: export PYTHONHOME=<path to your python distribution>

ylikx avatar Jul 12 '19 12:07 ylikx