Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matplotlib Example Fails #5

Open
OrbitalMechanic opened this issue Jul 10, 2019 · 3 comments
Open

Matplotlib Example Fails #5

OrbitalMechanic opened this issue Jul 10, 2019 · 3 comments

Comments

@OrbitalMechanic
Copy link

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

@ylikx
Copy link
Owner

ylikx commented Jul 10, 2019

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

@econwang
Copy link

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.

@ylikx
Copy link
Owner

ylikx commented Jul 12, 2019

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants