Replies: 2 comments 2 replies
-
You have to manually add its path to Settings::path |
Beta Was this translation helpful? Give feedback.
1 reply
-
For future readers, this is the solution:
let interp = vm::Interpreter::with_init(settings, |vm| {
vm.add_native_modules(rustpython_stdlib::get_module_inits());
vm.add_frozen(rustpython_pylib::FROZEN_STDLIB);
});
let site_result = vm.import("site", 0);
if site_result.is_err() {
println!(
"Failed to import site, consider adding the Lib directory to your RUSTPYTHONPATH \
environment variable",
);
}
vm.run_code_string(
vm.new_scope_with_builtins(),
"import sys; sys.path.insert(0, '')",
"<embedded>".to_owned(),
)?; |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello. I'm having trouble figuring out how to use venv modules with rustpython-vm. This part seems fine:
However, when I try to do this from Rust source code, I get
ModuleNotFoundError: No module named 'textdistance'
. I have tried variants of the following, e.g. to add the VIRTUAL_ENV via insert_sys_path, and i also tried adding it viasettings.path_list.push(...)
. I have also tried the release 0.4.0, and pointing to the main branch of the github repo. I have tried copying some of the bits from what i know works, the rustpython cli source: https://github.com/RustPython/RustPython/blob/main/src/lib.rs, e.g. the lines 164-168 and setting RUSTPYTHON, ... all to no avail.Beta Was this translation helpful? Give feedback.
All reactions