PyO3 / pyo3

Rust bindings for the Python interpreter
https://pyo3.rs
Apache License 2.0
12.29k stars 758 forks source link

ImportError: DLL load failed while importing _rust : The specified module could not be found #3425

Closed CoderYunTang closed 1 year ago

CoderYunTang commented 1 year ago

Bug Description

Python::with_gil(|py| { let ts = py.import("cryptography.hazmat.bindings._rust"); if let Err(err) = ts { println!("{}", err); } }

ImportError: DLL load failed while importing _rust : The specified module could not be found

Importing with the python interpreter is no problem: image

Steps to Reproduce

  1. python3.11.5
  2. windows 10
  3. py.import("cryptography.hazmat.bindings._rust");
  4. ImportError: DLL load failed while importing _rust : The specified module could not be found

Backtrace

No response

Your operating system and version

Windows 10

Your Python version (python --version)

python 3.11.5

Your Rust version (rustc --version)

rustc 1.70.0

Your PyO3 version

0.19.2

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

https://www.python.org/

Additional Info

No response

davidhewitt commented 1 year ago

Do you use a virtualenv? This is probably just #1896

CoderYunTang commented 1 year ago

The same goes for not using a virtual environment. I've tried a lot of things and they don't work.

CoderYunTang commented 1 year ago

I tried it on another computer and it was the same

davidhewitt commented 1 year ago

Have you checked what libraries the cryptography extension is linked against, and are they available on your PATH when running your program?

chatdeschroedinger commented 9 months ago

I had the same issue with a venv on windows with python 3.9.1 The issue was solved by upgrading to python 3.9.7

austin-Q-ai commented 8 months ago

I have got a same issue when usign scrapy for web scraping does anyone help me?

davidhewitt commented 8 months ago

@QsageHint what OS? What steps did you take to set up your environment and install cryptography?

austin-Q-ai commented 8 months ago

OS: Windows 10 PythonL 3.9.0 I have create virtual environment using virtualenv (20.25.1), and installed scrapy (2.11.1) Of course, I have installed MSVC and windows sdk

davidhewitt commented 8 months ago

Can you try a newer Python version? It seemed like just above 3.9.1 had a problem and I wonder if we'll see the same thing here.

austin-Q-ai commented 8 months ago

Good I have just installed python 3.9.13 and now it is working well

richyk1 commented 8 months ago

Good I have just installed python 3.9.13 and now it is working well

I'm using pyenv so I just upgraded my Python version to 3.10.0 and it seems to have fixed the issue. I did: pyenv install 3.10.0 pyenv global 3.10.0

austin-Q-ai commented 8 months ago

yes, I think upgrading is the solution with this issue