Creating an executable file from a Python script

OMIDMahmoodi Posts: 3 Calcite Rank Badge
edited February 23 in GeoStudio
Hi, I wrote a Python script to calculate the time decay constant for time-domain EM data, and it works well. But when I build an executable file from the Python script using cx_Freeze, I can't run the program. I get an Python error of "File NotFoundError" (attached image) caused by a file named "\geosoft\pkg_info.json".
I'd really appreciate it if anyone could help me with this.



  • Based on the error message, you just need to place pkg_info.json in your ...\\geosoft\ folder. You will find a copy here:
    Geosoft logo
  • Hi,

    Since cx_Freeze by default only embeds the Python files you will likely need to follow these instructions to either find the files elsewhere in relation to your executable or embed them using Qt resources:

    You will also probably need to place the dlls, geosoft.key file and pyd modules in the geosoft\gxapi directory next to your exe.

    Disclaimer; I have not actually attempted this, but I'm pretty sure this should work.


  • Thanks for your responses. @IanMacLeod : copy/paste the pkg_info.json didn't solve the problem. Now, I'm trying @JacquesBeaurain 's solution. I had read that article, but I couldn't understand where I should paste the code : def find_data_file(filename): ..... .
    I assume it should be in the file (the file that executes cx_Freeze). Is there any modification that should be made to the for geosoft or the code: def find_data_file(filename): ?

  • If it is only pkg_info.json, you can also modify to set the version variable yourself.

    I suspect this may just move you on to the next problem, so as Jacques suggest, dig into the cx_Freeze docs to better understand how it packages resources. I can't help much there.
    Geosoft logo
This discussion has been closed.