I'm trying to embed python into a C application. For the moment, I am trying to get the following hello world style example working
#include <..../anaconda3/include/python3.7m/Python.h> // I've abbreviated this path for privacy
int main()
{
Py_Initialize();
PyRun_SimpleString("from time import time,ctime\nprint('Today is', ctime(time()))\n");
Py_FinalizeEx();
return(EXIT_SUCCESS);
}
I've been able to compile this example but I get the following error when I run it
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
I have multiple versions of python installed (python3, I'm using macOS) and want to run a specific anaconda version that I have installed. As I understand the above problem, the reason I am getting this error is because I need to give a the specific path for python to look for libraries/modules. Setting PYTHONHOME and/or PYTHONPATH should fix this problem then. However, I'm not sure what I should set this value to.
My question is two fold. (1) Have I correctly diagnosed the problem? (2) If so, what should I set these two environment variables to? Specifically, what are the specific paths? While there have been several other posts regarding this problem none seem to give the what the paths should be (I've tried setting just the PYTHONHOME variable to "..../anaconda" since one of the answers in this post stated that it should be set to the parent folder of the bin file of python which in this case is anaconda. Doing this did not fix the problem.).
Edit:
Applying the changes suggested by @John Bollinger seems to partially solve the problem. The resulting error is now
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'