pyo3 icon indicating copy to clipboard operation
pyo3 copied to clipboard

Rust analyzer fails to pick up Pyo3 proc-macros

Open Ruhrpottpatriot opened this issue 11 months ago • 1 comments

Bug Description

When using pyo3 inside VSCode with rust-analyzer, rust-analyzer fails to compile the proc macros. See the attacked image.

Image

Steps to Reproduce

  1. Create a new virtual environment with python -m venv .venv
  2. Activate the new virtual environment
  3. Install Maturin with pip install maturin
  4. Create a new maturin project with maturin init --name foo
  5. Open the lib.rs file and see rust-analyzer complaining

Backtrace


Your operating system and version

Windows 10 10.0.19045 Build 19045

Your Python version (python --version)

Python 3.12

Your Rust version (rustc --version)

rustc 1.84.1 (e71f9a9a9 2025-01-27)

Your PyO3 version

0.23.3

How did you install python? Did you use a virtualenv?

python -m venv .venv

Additional Info

No response

Ruhrpottpatriot avatar Feb 14 '25 14:02 Ruhrpottpatriot

Can you please open the vscode output window for the rust analyzer server and check for any relevant contents? Usually there is build error output there if there's an issue.

For what it's worth, this is working fine for me.

davidhewitt avatar Apr 06 '25 16:04 davidhewitt

@davidhewitt Probably because the virtual environment is not loaded, I don't use .venv\Scripts\activate to enter vscode it's the same error (AB Experiments with python plugins disabled).

  • There is no python environment set globally

MaxKingPor avatar Jul 14 '25 06:07 MaxKingPor