Home:ALL Converter>Static python build missing modules

Static python build missing modules

Ask Time:2015-01-10T12:30:05         Author:0xSingularity

Json Formatter

I recently needed a static version of python in one of my projects, so i got the source and built it. After linking it to my application when I run it I am missing all of the required modules and I don't know where to put them.

Errors:

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
'import site' failed; use -v for traceback
Traceback (most recent call last):
    File "<string>", line 1, in <module>
ImportError: No module named time

Code:

#include <Python.h>

int main(int argc, char *argv[])
{
Py_SetProgramName(argv[0]);  /* optional but recommended */
Py_Initialize();
PyRun_SimpleString("from time import time,ctime\n"
                 "print 'Today is',ctime(time())\n");
Py_Finalize();
return 0;

}

Code for building exe:

gcc main.c -I/Desktop/Python-2.6.4 -I//Desktop/Python-2.6.4/Include -I/Desktop/Python-2.6.4/Modules -L/Desktop/Python-2.6.4 -lpython2.6 -static

Tutorial for building python statically

If someone could tell me where to put these modules or even better tell me how to link them statically, it would be much appreciated!

Author:0xSingularity,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/27872864/static-python-build-missing-modules
yy