-
I need to do it without any other extra tool like pyoxidizer, pyembed and such. Is it possible to achieve this only with pyo3? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Adding more info: I want to set it up to python-3.10.7-embed-amd64.zip. So far, I'm trying to use pyo3-ffi. unsafe {
pyo3_ffi::Py_SetPythonHome(widestring::u16cstr!("D:\\dev\\sensorial\\systems\\pip\\redist\\python310").as_ptr());
}
pyo3::prepare_freethreaded_python();
Python::with_gil(|gil| {
let sys = gil.import("sys");
let version: String = sys.expect("").getattr("version").unwrap().extract().unwrap();
println!("{}", version);
}); But this fails with: Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ImportError: bad magic number in 'encodings': b'o\r\r\n'
Current thread 0x000037e8 (most recent call first):
<no Python frame> It seems like the folder structure is incorrect (maybe I have to unpack python310.zip). I will continue investigating. |
Beta Was this translation helpful? Give feedback.
-
(Only tested on Windows) |
Beta Was this translation helpful? Give feedback.
(Only tested on Windows)
Setting
PYTHONHOME
to the directory containing python.exe seems to be enough.I also needed to make sure the DLLs were copied to the compiled executable folder.