diff --git a/guide/src/faq.md b/guide/src/faq.md index c755a5eb..f0e64170 100644 --- a/guide/src/faq.md +++ b/guide/src/faq.md @@ -183,12 +183,17 @@ struct MyClass; ## I'm trying to call Python from Rust but I get `STATUS_DLL_NOT_FOUND` or `STATUS_ENTRYPOINT_NOT_FOUND`! -This happens on Windows when linking to the python DLL fails or the wrong one is linked. Your `PATH` variable should contain something like... +This happens on Windows when linking to the python DLL fails or the wrong one is linked. The Python DLL on Windows will usually be called something like: +- `python3X.dll` for Python 3.X, e.g. `python310.dll` for Python 3.10 +- `python3.dll` when using PyO3's `abi3` feature -```text -C:\Users\\AppData\Local\Programs\Python\Python310 -``` +The DLL needs to be locatable using the [Windows DLL search order](https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#standard-search-order-for-unpackaged-apps). The two easiest ways to achieve this are: +- Put the Python DLL in the same folder as your build artifacts +- Add the directory containing the Python DLL to your `PATH` environment variable, for example `C:\Users\\AppData\Local\Programs\Python\Python310` +- If this happens when you are *distributing* your program, consider using [PyOxidizer](https://github.com/indygreg/PyOxidizer) to package it with your binary. -This directory should have, for Python 3.10, the files `python3.dll` and `python310.dll`. If you have made any changes to your `PATH` or installed things recently, try restarting your shell - any changes will not affect already open shells. +If the wrong DLL is linked it is possible that this happened because another program added itself and its own Python DLLs to `PATH`. Rearrange your `PATH` variables to give the correct DLL priority. -Failing that, you can use [Dependency Walker](https://www.dependencywalker.com/) to diagnose linking errors. +> **Note**: Changes to `PATH` (or any other environment variable) are not visible to existing shells. Restart it for changes to take effect. + +For advanced troubleshooting, [Dependency Walker](https://www.dependencywalker.com/) can be used to diagnose linking errors.