Mojo - Instalasi dan Memulai Coding

Posted in: Software  
Tags: AlmaLinux   Mojo   modular   Instalasi   Konfigurasi   IDE   Visual Studio Code  
Author: Bambang Purnomosidi D. P. | | 8 minutes reading time

Update (22 Maret 2024):

  1. Perubahan cara instalasi.
  2. Menggunakan AlmaLinux.

Tentang Mojo

Mojo adalah bahasa pemrograman baru yang diarahkan ke para pengembang software bidang AI (Artificial Intelligence). Mojo muncul karena keluhan lamanya eksekusi program AI yang dibangun menggunakan Python, sementara itu ekosistem AI di Python sedemikian kuat dan berlimpah (barangkali tidak ada bahasa pemrograman lain yang menandingi). “Ketidakberdayaan” para pengembang software AI berbasis Python tersebut yang memicu munculnya Mojo: tidak menyukai lambatnya program AI tetapi tidak bisa lepas dari Python karena matangnya ekosistem AI di Python.

Mojo menggunakan sintaksis Python dengan penambahan minor sehingga bisa dikatakan bahwa Mojo adalah superset dari Python. Meskipun penggunaan utama dari Mojo adalah AI, Mojo juga merupakan general purpose programming language, artinya bisa digunakan untuk keperluan umum pemrograman.

Instalasi Mojo

Mojo memerlukan beberapa prasyarat (Linux):

  1. Python (3.8 - 3.11).
  2. Kompilator g++ atau clang++.
  3. Distro Linux berbasis Ubuntu/Debian, lebih spesifik >= 20.04
  4. CPU X86_64
  5. RAM minimal 4GB

Tool utama yang harus di-install adalah modular cli. modular adalah program yang dijalankan dari shell untuk berinteraksi dengan produk perusahaan modular (Mojo diproduksi oleh Modular). Install modular dengan perintah berikut (sebagai root):

$ curl -s https://get.modular.com | sh -
[sudo] password for bpdp: 
Executing the  setup script for the 'modular/installer' repository ...

   OK: Checking for required executable 'curl' ...
   OK: Checking for required executable 'rpm' ...
   OK: Detecting your OS distribution and release using system methods ...
 ^^^^: ... Detected/provided for your OS/distribution, version and architecture:
 >>>>:
 >>>>: ... distro=almalinux  version=9.3  codename=Shamrock  arch=x86_64  
 >>>>:
   OK: Importing 'modular/installer' repository GPG keys into rpm ...
   OK: Checking for available package manager (DNF/Microdnf/YUM/Zypper) ...
 ^^^^: ... Detected package manager as 'dnf'
   OK: Checking for dnf dependency 'dnf-plugins-core' ...
   OK: Checking if upstream install config is OK ...
   OK: Fetching 'modular/installer' repository configuration ...
   OK: Installing 'modular/installer' repository via dnf ...
  RUN: Updating the dnf cache to fetch the new repository metadata ...Importing GPG key 0x7A3895AD:
 Userid     : "Cloudsmith Package (modular/installer) <support@cloudsmith.io>"
 Fingerprint: 0BAB A1B0 518C 87CF F4CC 3740 0E49 2573 7A38 95AD
 From       : https://dl.modular.com/public/installer/gpg.0E4925737A3895AD.key
Importing GPG key 0x7A3895AD:
 Userid     : "Cloudsmith Package (modular/installer) <support@cloudsmith.io>"
 Fingerprint: 0BAB A1B0 518C 87CF F4CC 3740 0E49 2573 7A38 95AD
 From       : https://dl.modular.com/public/installer/gpg.0E4925737A3895AD.key
Importing GPG key 0x7A3895AD:
 Userid     : "Cloudsmith Package (modular/installer) <support@cloudsmith.io>"
 Fingerprint: 0BAB A1B0 518C 87CF F4CC 3740 0E49 2573 7A38 95AD
 From       : https://dl.modular.com/public/installer/gpg.0E4925737A3895AD.key
   OK: Updating the dnf cache to fetch the new repository metadata ...
   OK: The repository has been installed successfully - You're ready to rock!


Installed:
  modular-0.5.2-1.x86_64                                                                                                                                                

  __  __           _       _
 |  \/  | ___   __| |_   _| | __ _ _ __
 | |\/| |/ _ \ / _` | | | | |/ _` | '__|
 | |  | | (_) | (_| | |_| | | (_| | |
 |_|  |_|\___/ \__,_|\__,_|_|\__,_|_|

Welcome to the Modular CLI!

To get started, see:
https://modul.ar/get-started

For info about this tool, type "modular --help".
$

Catatan: Jika anda menggunakan Linux, instalasi modular hanya bisa dilakukan pada sistem operasi berbasis Debian/Ubuntu dan RedHat

Pada posisi ini, kita akan menginstall mojo sebagai user biasa. Setelah modular terinstall, konfigurasikan otentikasi:

$ modular auth 

Untuk instalasi Python, bisa digunakan miniconda.Untuk keperluan tersebut, setelah install miniconda, buat virtual environment baru menggunakan Python versi 3.11:

$ conda create -n py311-mojo python=3.11
Channels:
 - defaults
 - conda-forge
Platform: linux-64
Collecting package metadata (repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /home/bpdp/software/python-dev-tools/miniconda39/envs/py311-mojo

  added / updated specs:
    - python=3.11


The following NEW packages will be INSTALLED:

  _libgcc_mutex      pkgs/main/linux-64::_libgcc_mutex-0.1-main 
  _openmp_mutex      pkgs/main/linux-64::_openmp_mutex-5.1-1_gnu 
  bzip2              pkgs/main/linux-64::bzip2-1.0.8-h7b6447c_0 
  ca-certificates    pkgs/main/linux-64::ca-certificates-2023.08.22-h06a4308_0 
  ld_impl_linux-64   pkgs/main/linux-64::ld_impl_linux-64-2.38-h1181459_1 
  libffi             pkgs/main/linux-64::libffi-3.4.4-h6a678d5_0 
  libgcc-ng          pkgs/main/linux-64::libgcc-ng-11.2.0-h1234567_1 
  libgomp            pkgs/main/linux-64::libgomp-11.2.0-h1234567_1 
  libstdcxx-ng       pkgs/main/linux-64::libstdcxx-ng-11.2.0-h1234567_1 
  libuuid            pkgs/main/linux-64::libuuid-1.41.5-h5eee18b_0 
  ncurses            pkgs/main/linux-64::ncurses-6.4-h6a678d5_0 
  openssl            pkgs/main/linux-64::openssl-3.0.12-h7f8727e_0 
  pip                pkgs/main/linux-64::pip-23.3-py311h06a4308_0 
  python             pkgs/main/linux-64::python-3.11.5-h955ad1f_0 
  readline           pkgs/main/linux-64::readline-8.2-h5eee18b_0 
  setuptools         pkgs/main/linux-64::setuptools-68.0.0-py311h06a4308_0 
  sqlite             pkgs/main/linux-64::sqlite-3.41.2-h5eee18b_0 
  tk                 pkgs/main/linux-64::tk-8.6.12-h1ccaba5_0 
  tzdata             pkgs/main/noarch::tzdata-2023c-h04d1e81_0 
  wheel              pkgs/main/linux-64::wheel-0.41.2-py311h06a4308_0 
  xz                 pkgs/main/linux-64::xz-5.4.2-h5eee18b_0 
  zlib               pkgs/main/linux-64::zlib-1.2.13-h5eee18b_0 


Proceed ([y]/n)? y


Downloading and Extracting Packages:

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate py311-mojo
#
# To deactivate an active environment, use
#
#     $ conda deactivate

Setelah itu aktifkan:

$ conda activate py311-mojo

Catatan: membuat environment baru hanya perlu dikerjakan sekali, sementara itu untuk mengaktifkasn (conda activate) dilaksanakan setiap akan memulai aktivitas coding menggunakan Mojo.

Setelah itu, install Mojo:

$ modular install mojo
# Found release for https://packages.modular.com/mojo @ 0.5.0
# Installing to /home/bpdp/.modular/pkg/packages.modular.com_mojo
# Downloading artifacts. Please wait...
# Downloads complete, setting configs...
# Configs complete, running post-install hooks...
Requirement already satisfied: find_libpython==0.3.0 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from -r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 1)) (0.3.0)
Requirement already satisfied: papermill==2.4.0 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from -r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (2.4.0)
Requirement already satisfied: jupyter_client>=8.3.0 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from -r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 3)) (8.6.0)
Requirement already satisfied: ipykernel>=6.25.0 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from -r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 4)) (6.26.0)
Requirement already satisfied: ansiwrap in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from papermill==2.4.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (0.8.4)
Requirement already satisfied: click in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from papermill==2.4.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (8.1.7)
Requirement already satisfied: pyyaml in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from papermill==2.4.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (6.0.1)
Requirement already satisfied: nbformat>=5.1.2 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from papermill==2.4.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (5.9.2)
Requirement already satisfied: nbclient>=0.2.0 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from papermill==2.4.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (0.9.0)
Requirement already satisfied: tqdm>=4.32.2 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from papermill==2.4.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (4.66.1)
Requirement already satisfied: requests in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from papermill==2.4.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (2.31.0)
Requirement already satisfied: entrypoints in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from papermill==2.4.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (0.4)
Requirement already satisfied: tenacity in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from papermill==2.4.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (8.2.3)
Requirement already satisfied: jupyter-core!=5.0.*,>=4.12 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from jupyter_client>=8.3.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 3)) (5.5.0)
Requirement already satisfied: python-dateutil>=2.8.2 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from jupyter_client>=8.3.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 3)) (2.8.2)
Requirement already satisfied: pyzmq>=23.0 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from jupyter_client>=8.3.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 3)) (25.1.1)
Requirement already satisfied: tornado>=6.2 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from jupyter_client>=8.3.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 3)) (6.3.3)
Requirement already satisfied: traitlets>=5.3 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from jupyter_client>=8.3.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 3)) (5.13.0)
Requirement already satisfied: comm>=0.1.1 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from ipykernel>=6.25.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 4)) (0.2.0)
Requirement already satisfied: debugpy>=1.6.5 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from ipykernel>=6.25.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 4)) (1.8.0)
Requirement already satisfied: ipython>=7.23.1 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from ipykernel>=6.25.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 4)) (8.17.2)
Requirement already satisfied: matplotlib-inline>=0.1 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from ipykernel>=6.25.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 4)) (0.1.6)
Requirement already satisfied: nest-asyncio in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from ipykernel>=6.25.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 4)) (1.5.8)
Requirement already satisfied: packaging in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from ipykernel>=6.25.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 4)) (23.2)
Requirement already satisfied: psutil in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from ipykernel>=6.25.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 4)) (5.9.6)
Requirement already satisfied: decorator in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from ipython>=7.23.1->ipykernel>=6.25.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 4)) (5.1.1)
Requirement already satisfied: jedi>=0.16 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from ipython>=7.23.1->ipykernel>=6.25.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 4)) (0.19.1)
Requirement already satisfied: prompt-toolkit!=3.0.37,<3.1.0,>=3.0.30 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from ipython>=7.23.1->ipykernel>=6.25.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 4)) (3.0.41)
Requirement already satisfied: pygments>=2.4.0 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from ipython>=7.23.1->ipykernel>=6.25.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 4)) (2.16.1)
Requirement already satisfied: stack-data in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from ipython>=7.23.1->ipykernel>=6.25.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 4)) (0.6.3)
Requirement already satisfied: pexpect>4.3 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from ipython>=7.23.1->ipykernel>=6.25.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 4)) (4.8.0)
Requirement already satisfied: platformdirs>=2.5 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from jupyter-core!=5.0.*,>=4.12->jupyter_client>=8.3.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 3)) (4.0.0)
Requirement already satisfied: fastjsonschema in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from nbformat>=5.1.2->papermill==2.4.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (2.19.0)
Requirement already satisfied: jsonschema>=2.6 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from nbformat>=5.1.2->papermill==2.4.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (4.20.0)
Requirement already satisfied: six>=1.5 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from python-dateutil>=2.8.2->jupyter_client>=8.3.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 3)) (1.16.0)
Requirement already satisfied: textwrap3>=0.9.2 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from ansiwrap->papermill==2.4.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (0.9.2)
Requirement already satisfied: charset-normalizer<4,>=2 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from requests->papermill==2.4.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from requests->papermill==2.4.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from requests->papermill==2.4.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (2.1.0)
Requirement already satisfied: certifi>=2017.4.17 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from requests->papermill==2.4.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (2023.7.22)
Requirement already satisfied: parso<0.9.0,>=0.8.3 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from jedi>=0.16->ipython>=7.23.1->ipykernel>=6.25.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 4)) (0.8.3)
Requirement already satisfied: attrs>=22.2.0 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from jsonschema>=2.6->nbformat>=5.1.2->papermill==2.4.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (23.1.0)
Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from jsonschema>=2.6->nbformat>=5.1.2->papermill==2.4.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (2023.11.1)
Requirement already satisfied: referencing>=0.28.4 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from jsonschema>=2.6->nbformat>=5.1.2->papermill==2.4.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (0.31.0)
Requirement already satisfied: rpds-py>=0.7.1 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from jsonschema>=2.6->nbformat>=5.1.2->papermill==2.4.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (0.13.0)
Requirement already satisfied: ptyprocess>=0.5 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from pexpect>4.3->ipython>=7.23.1->ipykernel>=6.25.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 4)) (0.7.0)
Requirement already satisfied: wcwidth in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from prompt-toolkit!=3.0.37,<3.1.0,>=3.0.30->ipython>=7.23.1->ipykernel>=6.25.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 4)) (0.2.10)
Requirement already satisfied: executing>=1.2.0 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from stack-data->ipython>=7.23.1->ipykernel>=6.25.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 4)) (2.0.1)
Requirement already satisfied: asttokens>=2.1.0 in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from stack-data->ipython>=7.23.1->ipykernel>=6.25.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 4)) (2.4.1)
Requirement already satisfied: pure-eval in /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv/lib/python3.11/site-packages (from stack-data->ipython>=7.23.1->ipykernel>=6.25.0->-r /home/bpdp/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 4)) (0.2.2)

🔥 Mojo installed! 🔥

Mojo's Python virtual environment created at /home/bpdp/.modular/pkg/packages.modular.com_mojo/venv

If you are using ZSH (default on macOS), run the following commands:

echo 'export MODULAR_HOME="/home/bpdp/.modular"' >> ~/.zshrc
echo 'export PATH="/home/bpdp/.modular/pkg/packages.modular.com_mojo/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

If you are using bash, run the following commands:

BASHRC=$( [ -f "$HOME/.bash_profile" ] && echo "$HOME/.bash_profile" || echo "$HOME/.bashrc" )
echo 'export MODULAR_HOME="/home/bpdp/.modular"' >> "$BASHRC"
echo 'export PATH="/home/bpdp/.modular/pkg/packages.modular.com_mojo/bin:$PATH"' >> "$BASHRC"
source "$BASHRC"

Then enter 'mojo' to start the Mojo REPL.

For tool help, enter 'mojo --help'.
For more docs, see https://docs.modular.com/mojo.
$

Setelah terinstall, perhatikan dan kerjakan petunjuk untuk zsh maupun bash di atas. Saya menggunakan fish sehingga saya hanya perlu menyimpan variabel lingkukan dalam suatu file dan kemudian tinggal source saat memerlukan:

$ cat ~/env/fish/mojo
set -x MODULAR_HOME /home/bpdp/.modular
set -x PATH /home/bpdp/.modular/pkg/packages.modular.com_mojo/bin $PATH
$

Saat akan menggunakan mojo, source:

$ source ~/env/fish/mojo

Mojo REPL

Untuk memastika bahwa Mojo telah terinstall, jalankan Mojo REPL:

$ mojo
Welcome to Mojo! 🔥

Expressions are delimited by a blank line.
Type `:quit` to exit the REPL and `:mojo help` for further assistance.

  1> :quit
Process 23183 exited with status = 9 (0x00000009) killed
$

IDE: Visual Studio Code + Mojo Extension

Modular juga menyediakan extenstion untuk IDE - Visual Studio Code. Install extension berikut ini:

Instalasi Mojo extension

Untuk memulai membuat source code, seperti biasa, pilih File - New File, beri nama dan ekstensi file (untuk ekstensi, bisa copy dari image api yang ada pada dokumentasi Mojo).

Aktifkan terminal terlebih dahulu. Setelah itu, untuk menjalankan, pada posisi kanan atas, terdapat pilihan bertanda panah, klik dan pilih Run Mojo File. Perhatikan hasil berikut ini:

Menjalankan source code bahasa pemrograman Mojo

Setelah selesai, kita sudah mulai bisa menggunakan Visual Studio Code maupun modular serta mojo. Have fun!