mojo
mojo copied to clipboard
[Mojo] Exception: Could not find libpython.
Environment: Windows WSL
When I run modular install mojo
, it occurs an error of no libpython, I try many ways to change $LD_LIBRARY_PATH
, but the error isn't fixed.
Here are detailed errror:
Traceback (most recent call last):
File "/home/junital/.modular/pkg/packages.modular.com_mojo/scripts/post-install/pick_python.py", line 67, in <module>
main()
File "/home/junital/.modular/pkg/packages.modular.com_mojo/scripts/post-install/pick_python.py", line 50, in main
raise Exception(
Exception: Could not find libpython. Check your Python installation and ensure that $LD_LIBRARY_PATH includes the location to the installed Python library (e.g. /usr/lib/x86_64-linux-gnu).
Facing same issue
Hi do a search on your system for libpython:
sudo find / -name 'libpython*.so'
For example this might show up amongst others:
/opt/conda/lib/libpython3.10.so
/opt/conda/lib/libpython3.so
So before installing the cli you can add the directory that libpython*.so
was in:
export LD_LIBRARY_PATH="/opt/conda/lib:$LD_LIBRARY_PATH"
Now after install you'll find in ~/.modular/modular.cfg
there will be a key:
python_lib = /opt/conda/lib/libpython3.10.so
Which you can change after install if you like.
Sorry but here are still some issues: When I try to find libpython:
sudo find / -name 'libpython*.so'
Here is my result:
/usr/lib/x86_64-linux-gnu/libpython3.10.so
/usr/lib/python3.10/config-3.10-x86_64-linux-gnu/libpython3.10.so
My LD_LIBRARY_PATH:
echo $LD_LIBRARY_PATH
/usr/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu/
But when I install mojo, the issue isn't fixed.
Here are some clues:
python3.10 /home/junital/.modular/pkg/packages.modular.com_mojo/scripts/post-install/pick_python.py
ModuleNotFoundError: No module named 'find_libpython'
python3.9 /home/junital/.modular/pkg/packages.modular.com_mojo/scripts/post-install/pick_python.py
Exception: Could not find libpython. Check your Python installation and ensure that $LD_LIBRARY_PATH includes the location to the installed Python library (e.g. /usr/lib/x86_64-linux-gnu).
I think it uses python3.9 to run the code instead of python3.10.
I ran into this issue while using pyenv. I resolved it by installing an updated python version using PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install -v 3.11.5
and then activating that as my global pyenv version.
After installing that version I installed mojo with LD_LIBRARY_PATH="~/.pyenv/versions/3.11.5/lib/"
but that may or may not have been necessary.
I hope this helps anyone who runs into this issue while using pyenv.
I faced the same error on M2 Mac with macOS 14.0.
Changing global pyenv from 3.9 into 3.11 using PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install -v 3.11.3
,
solved it too.
Thanks @BTripp1986!
quick confirmation here, the other approaches did not work for me (setting the key in ~/.modular/modular.cfg
)
what did work:
- update:
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install -v 3.11.5
- activate global:
pyenv global 3.11.5
- set library path:
LD_LIBRARY_PATH="/Users/[USERNAME]/.pyenv/versions/3.11.5/lib"
- clean and install:
modular clean && modular install mojo
thanks!
Current versions of python (3.11, 3.12) compiled under linux default to building a static (.a
) rather than shared (.so
) version of libpython. Rebuilding after ./configure --enable-shared
builds libpython3.so
but neither the mojo installer nor python itself could find the library in the default install location of /usr/local/lib
.
Setting LD_LIBRARY_PATH
did not help, but per this SO question adding /usr/local/lib
to /etc/ld.so.conf
and running sudo ldconfig
resolved the linkage issue for both python and the mojo installer. (Probably this could have been avoided by using the correct configure option for shared library paths.)
I ran into this issue while using pyenv. I resolved it by installing an updated python version using
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install -v 3.11.5
and then activating that as my global pyenv version.After installing that version I installed mojo with
LD_LIBRARY_PATH="~/.pyenv/versions/3.11.5/lib/"
but that may or may not have been necessary.I hope this helps anyone who runs into this issue while using pyenv.
This helped, but what did it for me was running modular clean
before retrying my install.
Resolved by https://github.com/modularml/mojo/commit/b6776222dbd1e2e72a5e6f772d01b35fee7ea0d9. Mojo now finds libpython using the python executable on the top of PATH
.
Please try again with modular install mojo
or modular install max
, if it still fails try running the script in https://modul.ar/fix-python, if you don't have a compatible python on PATH
, you can install conda using that same guide.