I am trying to embed the python zip file in my application. I downloaded the zip file from the python site, (the win32 one).
This is the code I use to set the python path
#include <Python.h>
...
std::wstring exe_dir = L"\\exe\\path";
std::wstring python_path;
python_path += exe_dir + L"python-3.5.1-embed-win32.zip";
Py_SetPath(python_path.c_str());
Py_Initialize(); // Error : "Py_Initialize: unable to load the file system codec"
...
But no matter what I do, the app throw the same error all the time. Even if I play around with various path.
How can I embed the zip file in my app?
Installing PythonDownload the embeddable zip file from the link https://www.python.org/downloads/release/python-374/. Extract the archive or zip file into a physical drive location. Let's say under C drive. So the extracted python root directory is C:\python-3.7.
The embeddable package. New in version 3.5. The embedded distribution is a ZIP file containing a minimal Python environment. It is intended for acting as part of another application, rather than being directly accessed by end-users.
There is another zip file inside "python-3.5.1-embed-win32.zip".
python35.zip
And that file is the one that needs to be added.
#include <Python.h>
...
std::wstring exe_dir = L"\\exe\\path";
std::wstring python_path;
python_path += exe_dir + L"python35.zip";
Py_SetPath(python_path.c_str());
Py_Initialize();
...
I would be interested to know what the other files are for, (or if this is the correct way to use it) ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With