Mojoš„ Installation on Ubuntu 23.04 [Not Stable]
Warning: Not Stable, please DO NOT try it on production environment
The default Python3 version for Ubuntu 23.04 is 3.11, thus we must install version from 3.8 to 3.10 for Mojoš„ requirement.
Installation Guide
Sign in to https://developer.modular.com/signup?redirect=%2Fdownload to get the MODULAR_AUTH_TOKEN
Install modular
CLI
$ curl https://get.modular.com | \
MODULAR_AUTH=<MODULAR_AUTH_TOKEN> \
sh -
Install mojo
SDK via modular
command
$ modular install mojo
Output from Ubuntu 23.04 with Python3.11
$ modular install mojo
# Found release for https://packages.modular.com/mojo @ 0.2.1, installing to /home/user/.modular/pkg/packages.modular.com_mojo
# Downloads complete, setting configs...
# Configs complete, running post-install hooks...
error: externally-managed-environment
Ć This environment is externally managed
ā°ā> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.
See /usr/share/doc/python3.11/README.venv for more information.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
modular: error: failed to run python:
Build Python3.10 from Source Code [ref1] [ref2]
$ sudo apt install -y wget build-essential libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev
$ wget -c https://www.python.org/ftp/python/3.10.13/Python-3.10.13.tar.xz
$ tar -Jxf Python-3.10.13.tar.xz
$ cd Python-3.10.13/
$ ./configure --enable-optimizations --enable-shared
$ sudo make -j4 && sudo make altinstall
The python3.10
will be installed in /usr/local/bin/
$ which python3.10
/usr/local/bin/python3.10
$ which python3
/usr/bin/python3
$ python3 --version
Python 3.11.4
Config Python3 version with update-alternatives
command to make python3.10
as system python3
temporary. [ref]
$ sudo update-alternatives --list python3
update-alternatives: error: no alternatives for python3
$ sudo update-alternatives --list python
update-alternatives: error: no alternatives for python
$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.10 1
$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1
$ sudo update-alternatives --config python3
There are 2 choices for the alternative python3 (providing /usr/bin/python3).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/local/bin/python3.10 2 auto mode
1 /usr/bin/python3.11 1 manual mode
2 /usr/local/bin/python3.10 2 manual mode
Press <enter> to keep the current choice[*], or type selection number:
After config the python3
version for the system, please aware to check again.
$ python3 --version
Python 3.10.13
Finally, time to install mojo
again.
$ modular install mojo
After Installed, add modular path for system environment
## Bash
echo 'export MODULAR_HOME="$HOME/.modular"' >> ~/.bashrc
echo 'export PATH="$HOME/.modular/pkg/packages.modular.com_mojo/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
## ZSH
echo 'export MODULAR_HOME="$HOME/.modular"' >> ~/.zshrc
echo 'export PATH="$HOME/.modular/pkg/packages.modular.com_mojo/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
Ready to go
$ mojo
Error & Fix
modular: error: failure detected
modular: error: failure detected - please run `modular clean` and try again
==========================
Failure Information:
- Creating symlink for /home/user/.modular/pkg/packages.modular.com_mojo/lib/liblldb.so.18.0.0git -> /home/user/.modular/pkg/packages.modular.com_mojo/lib/liblldb.so failed: File exists
- Creating symlink for /home/user/.modular/pkg/packages.modular.com_mojo/lib/libMojoJupyter.so.18git -> /home/user/.modular/pkg/packages.modular.com_mojo/lib/libMojoJupyter.so failed: File exists
- Creating symlink for /home/user/.modular/pkg/packages.modular.com_mojo/lib/liblldb.so.18.0.0git -> /home/user/.modular/pkg/packages.modular.com_mojo/lib/liblldb.so.18git failed: File exists
- Creating symlink for /home/user/.modular/pkg/packages.modular.com_mojo/lib/libKGENCompilerRTShared.so.18git -> /home/user/.modular/pkg/packages.modular.com_mojo/lib/libKGENCompilerRTShared.so failed: File exists
- Creating symlink for /home/user/.modular/pkg/packages.modular.com_mojo/lib/libMojoLLDB.so.18git -> /home/user/.modular/pkg/packages.modular.com_mojo/lib/libMojoLLDB.so failed: File exists
- Creating symlink for /home/user/.modular/pkg/packages.modular.com_mojo/lib/libLLCLRuntimeGlobals.so.18git -> /home/user/.modular/pkg/packages.modular.com_mojo/lib/libLLCLRuntimeGlobals.so failed: File exists
- Creating symlink for /home/user/.modular/pkg/packages.modular.com_mojo/lib/libMSupportGlobals.so.18git -> /home/user/.modular/pkg/packages.modular.com_mojo/lib/libMSupportGlobals.so failed: File exists
==========================
$ module clean && modular install mojo
python3: error while loading shared libraries: libpython3.10.so.1.0: cannot open shared object file: No such file or directory
$ find /usr/local/lib/ -name "libpython*.so*"
/usr/local/lib/libpython3.10.so.1.0
/usr/local/lib/libpython3.so
/usr/local/lib/libpython3.10.so
$ export LD_LIBRARY_PATH="/usr/local/lib/:$LD_LIBRARY_PATH"
$ module clean && modular install mojo
Thanks for your time, hope this article can help you install mojo
in Ubuntu 23.04.