You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’ve faced quite a few challenges when building and running projects with PyO3 on systems that are fully managed by Python virtual environments. Most of the time, the issue boils down to errors like ld -lpython3.X not found. I wanted to share a workaround that worked for me.
On UNIX systems, you can see the specific directories ld searches by running the following command:
However, when using tools like uv, anaconda, etc., the Python installation is often standalone, and ld doesn’t know where to find the necessary libraries.
For example, with uv, the Python library is typically located in ~/.local/share/uv/python/cpython-{version}/lib. To fix this, you can configure ld to include this directory in its search path. For Python 3.13.1 on x86_64 Linux, you can do the following:
echo"/home/USER/.local/share/uv/python/cpython-3.13.1-linux-x86_64-gnu/lib"| sudo tee /etc/ld.so.conf.d/uv_python.conf
Then, reload the linker configuration using:
sudo ldconfig
After that, ld should be able to find the Python libraries correctly.
You can adapt this approach for any Python environment manager. I haven’t found clear documentation on this issue, so I hope this solution helps others who run into the same problem.
The text was updated successfully, but these errors were encountered:
Hello,
I’ve faced quite a few challenges when building and running projects with PyO3 on systems that are fully managed by Python virtual environments. Most of the time, the issue boils down to errors like
ld -lpython3.X not found
. I wanted to share a workaround that worked for me.On UNIX systems, you can see the specific directories
ld
searches by running the following command:This will output something like:
However, when using tools like
uv
,anaconda
, etc., the Python installation is often standalone, andld
doesn’t know where to find the necessary libraries.For example, with
uv
, the Python library is typically located in~/.local/share/uv/python/cpython-{version}/lib
. To fix this, you can configureld
to include this directory in its search path. For Python 3.13.1 on x86_64 Linux, you can do the following:Then, reload the linker configuration using:
After that,
ld
should be able to find the Python libraries correctly.You can adapt this approach for any Python environment manager. I haven’t found clear documentation on this issue, so I hope this solution helps others who run into the same problem.
The text was updated successfully, but these errors were encountered: