Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I import asyncio from the standard library? #4301

Open
Gelox opened this issue Nov 28, 2022 · 3 comments
Open

How do I import asyncio from the standard library? #4301

Gelox opened this issue Nov 28, 2022 · 3 comments

Comments

@Gelox
Copy link

Gelox commented Nov 28, 2022

I am not able to import asyncio when running python code, however that should exist in the standard library and there seems to be a python implementation of it in the repo.

@DimitrisJim
Copy link
Member

DimitrisJim commented Nov 29, 2022

I don't think asyncio is currently functional. I can import it though, how are you running it? Is it raising an import error?

@Gelox
Copy link
Author

Gelox commented Nov 29, 2022

I'm running it using this

let int = rustpython_vm::Interpreter::with_init(Default::default(), |vm| {
    vm.add_native_modules(rustpython_stdlib::get_module_inits());
    // ...
});

int.enter(|vm| {
    vm.insert_sys_path(vm.new_pyobj("./pythonfiles"))
        .expect("add path");

    let m = match vm.import("pyfile", None, 0) {
        Ok(m) => m,
        Err(e) => {
            vm.print_exception(e);
            panic!("Failed at importing python file");
        }
    };
});
import asyncio
# ...

This fails with

  File "/file/path/./pythonfiles/pyfile.py", line 1, in <module>
    import asyncio
ModuleNotFoundError: No module named 'asyncio'

@ishaan-jaff
Copy link

ishaan-jaff commented Dec 28, 2022

Are you using a virtual environment to run the project? Are you sure that the asyncio module is installed in this environment? Clerkie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants