indygreg / indygreg/PyOxidizer

pyembed macos compile error init_fs_encoding

Open
#702 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
6.2k
Forks
256
PR merge metrics
No merged PRs in 30d

Description

I am using macos and venv. I am trying to run python code with pyembed. I tried setting filesystem_encoding and the python path to the python from the venv

I took this from the bench and it works. I think the default should be updated to work out of the box.

```
config.interpreter_config.parse_argv = Some(false);
config.set_missing_path_configuration = false;
config.argv = Some(vec!["python".into()]);
config.interpreter_config.executable = Some("python".into());
```
```
Python path configuration:
PYTHONHOME = '/Users/user/code/rust/test/target/debug'
PYTHONPATH = (not set)
program name = '/Users/user/code/rust/test/target/debug/test'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = '/Users/user/code/rust/test target/debug/test'
sys.base_prefix = '/Users/frederik/code/rust/manga-image-translator/target/debug'
sys.base_exec_prefix = '/Users/user/code/rust/test/target/debug'
sys.platlibdir = 'lib'
sys.executable = '/Users/user/code/rust/test/target/debug/test'
sys.prefix = '/Users/user/code/rust/test/target/debug'
sys.exec_prefix = '/Users/user/code/rust/test/target/debug'
sys.path = [
'/Users/user/code/rust/test/target/debug/lib/python310.zip',
'/Users/user/code/rust/test/target/debug/lib/python3.10',
'/Users/user/code/rust/test/target/debug/lib/python3.10/lib-dynload',
]
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Dynamic("during initializing Python main: init_fs_encoding: failed to get the Python codec of the filesystem encoding")', src/main.rs:11:59
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
```
fn main() {
let mut config = OxidizedPythonInterpreterConfig::default();
config.interpreter_config.filesystem_encoding = Some("utf-8".to_string());
#config.interpreter_config.python_path_env = Some("/Users/user/code/rust/test/test/venv/bin/python".to_string());

// Initialize the Python interpreter
let gil = pyembed::MainPythonInterpreter::new(config).unwrap();
gil.with_gil(|py| {
let result = py.run("print('Hello, Python!')", None, None);
});
}
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the macOS virtualenv failure using the configuration shown in src/main.rs, then compare it with the working bench configuration and the interpreter settings in the report. Done means the default configuration initializes Python without the init_fs_encoding failure and the behavior is verified for this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.