pyo3-asyncio
pyo3-asyncio copied to clipboard
function or associated item not found in `PyModule`
Hello,
From the Py03 documentation I am trying out something similar to the example in the calling Python from Rust example 3.4. Executing existing Python code...
I have this setup, am running on Rasbian Linux on rust version rustc 1.75.0:
.
├── Cargo.lock
├── Cargo.toml
├── python_app
│ ├── app.py
│ └── utils
│ └── foo.py
└── src
└── main.rs
Where my toml file looks like:
[package]
name = "asyncio_tests"
version = "0.1.0"
edition = "2021"
# Cargo.toml dependencies
[dependencies]
pyo3 = { version = "0.20" }
pyo3-asyncio = { version = "0.20" }
app.py:
from utils.foo import bar
async def run():
result = await bar()
return result
foo.py:
import asyncio
async def bar():
await asyncio.sleep(1)
return "baz"
Cargo check and build I get this error:
bbartling@benspi:~/rust_stuff/asyncio_tests $ cargo clean
Removed 635 files, 249.1MiB total
bbartling@benspi:~/rust_stuff/asyncio_tests $ cargo check
Compiling autocfg v1.1.0
Compiling target-lexicon v0.12.14
Compiling proc-macro2 v1.0.79
Compiling unicode-ident v1.0.12
Compiling once_cell v1.19.0
Compiling libc v0.2.153
Compiling slab v0.4.9
Compiling lock_api v0.4.11
Checking futures-sink v0.3.30
Checking futures-core v0.3.30
Compiling quote v1.0.35
Compiling pyo3-build-config v0.20.3
Compiling syn v2.0.52
Compiling parking_lot_core v0.9.9
Checking futures-channel v0.3.30
Compiling memoffset v0.9.0
Compiling portable-atomic v1.6.0
Checking pin-project-lite v0.2.13
Checking memchr v2.7.1
Checking futures-task v0.3.30
Checking pin-utils v0.1.0
Checking scopeguard v1.2.0
Checking smallvec v1.13.1
Checking futures-io v0.3.30
Compiling heck v0.4.1
Checking cfg-if v1.0.0
Checking parking_lot v0.12.1
Checking unindent v0.2.3
Compiling indoc v2.0.4
Compiling pyo3-ffi v0.20.3
Compiling pyo3 v0.20.3
Compiling pyo3-macros-backend v0.20.3
Compiling futures-macro v0.3.30
Checking futures-util v0.3.30
Compiling pyo3-macros v0.20.3
Checking futures-executor v0.3.30
Checking futures v0.3.30
Checking pyo3-asyncio v0.20.0
Checking asyncio_tests v0.1.0 (/home/bbartling/rust_stuff/asyncio_tests)
error[E0599]: no method named `import_bound` found for struct `pyo3::Python` in the current scope
--> src/main.rs:11:14
|
10 | let syspath = py
| _______________________-
11 | | .import_bound("sys")?
| | -^^^^^^^^^^^^ help: there is a method with a similar name: `import`
| |_____________|
|
error[E0599]: no function or associated item named `from_code_bound` found for struct `pyo3::prelude::PyModule` in the current scope
--> src/main.rs:15:40
|
15 | let app: Py<PyAny> = PyModule::from_code_bound(py, &py_app, "", "")?
| ^^^^^^^^^^^^^^^
| |
| function or associated item not found in `PyModule`
| help: there is an associated function with a similar name: `from_code`
For more information about this error, try `rustc --explain E0599`.
error: could not compile `asyncio_tests` (bin "asyncio_tests") due to 2 previous errors
Any ideas to try?