Mojo🔥может и развивается, но он делает успехи, которые стоит отметить. Во-первых, это было ускорение в 35 000 раз по сравнению с Python, а теперь оно на 20 % быстрее, чем версия llama.c от Karpathy.

Mojo SDK в настоящее время доступен для систем Ubuntu Linux, но встроенная поддержка Windows еще не реализована на местном уровне. Хотя мы все с нетерпением ожидаем встроенной поддержки Mojo в Windows, существует изящный обходной путь, который позволит вам ощутить его мощь прямо сейчас. Используя потенциал подсистемы Linux через WSL2, вы можете беспрепятственно использовать Mojo на своем компьютере с Windows. Давайте углубимся в шаги, чтобы это произошло:

1. Создание основы с помощью расширений

  • Сначала скачайте и установите VS Code. Этот универсальный редактор кода предлагает расширения, которые облегчат нашу работу.
  • После запуска VS Code перейдите на рынок расширений и добавьте в свою настройку расширение WSL и расширение Mojo.

2. Интеграция Ubuntu с WSL2

  • Далее вам необходимо установить Ubuntu 22.04 for WSL. Эта версия без проблем работает со средой WSL2.
  • После установки запустите терминал Ubuntu. Это будет наш командный центр для следующих шагов.

Но перед установкой включите функцию Windows, как показано ниже.

Вы все равно можете столкнуться с проблемой с ядром «wsl2 требует обновления своего ядра», для этого загрузите пакет обновления ядра Linux, используя ссылку и шаг ниже.



После выполнения вышеуказанных шагов установите ядро ​​по умолчанию.

wsl - set-default-version 2

3. Установка модульного интерфейса командной строки

  • В терминале Ubuntu введите следующую команду для установки модульного интерфейса командной строки:
  • В терминале Ubuntu установите Modular CLI:
curl https://get.modular.com | \   MODULAR_AUTH=mut_14566b7976a045bba17c29214624cd06 \   sh -

4. Настройка Mojo SDK

  • Когда модульный интерфейс командной строки готов, пришло время подключить Mojo SDK. Просто введите:
modular install mojo

Setting up g++ (4:11.2.0-1ubuntu1) ...
update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode
Setting up build-essential (12.9ubuntu3) ...
Setting up libpython3-dev:amd64 (3.10.6-1~22.04) ...
Setting up python3-dev (3.10.6-1~22.04) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
/sbin/ldconfig.real: Can't link /usr/lib/wsl/lib/libnvoptix_loader.so.1 to libnvoptix.so.1
/sbin/ldconfig.real: /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link
__  __           _       _
 |  \/  | ___   __| |_   _| | __ _ _ __
 | |\/| |/ _ \ / _` | | | | |/ _` | '__|
 | |  | | (_) | (_| | |_| | | (_| | |
 |_|  |_|\___/ \__,_|\__,_|_|\__,_|_|
Welcome to the Modular CLI!
For info about this tool, type "modular --help".
To install Mojo🔥, type "modular install mojo".
For Mojo documentation, see https://docs.modular.com/mojo.
To chat on Discord, visit https://discord.gg/modular.
To report issues, go to https://github.com/modularml/mojo/issues.
mabaig@mabaig-tp:~$ modular install mojo
# Found release for https://packages.modular.com/mojo @ 0.2.1, installing to /home/mabaig/.modular/pkg/packages.modular.com_mojo
# Downloads complete, setting configs...
# Configs complete, running post-install hooks...
Defaulting to user installation because normal site-packages is not writeable
Collecting find_libpython==0.3.0
  Downloading find_libpython-0.3.0-py3-none-any.whl (8.5 kB)
Collecting papermill==2.4.0
  Downloading papermill-2.4.0-py3-none-any.whl (38 kB)
Collecting jupyter_client>=8.3.0
  Downloading jupyter_client-8.3.1-py3-none-any.whl (104 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 104.1/104.1 KB 2.9 MB/s eta 0:00:00
Collecting nbclient>=0.2.0
  Downloading nbclient-0.8.0-py3-none-any.whl (73 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 73.1/73.1 KB 3.5 MB/s eta 0:00:00
Collecting click
  Downloading click-8.1.7-py3-none-any.whl (97 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.9/97.9 KB 5.8 MB/s eta 0:00:00
Collecting nbformat>=5.1.2
  Downloading nbformat-5.9.2-py3-none-any.whl (77 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.6/77.6 KB 3.5 MB/s eta 0:00:00
Collecting entrypoints
  Downloading entrypoints-0.4-py3-none-any.whl (5.3 kB)
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from papermill==2.4.0->-r /home/mabaig/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 2)) (5.4.1)
Collecting tqdm>=4.32.2
  Downloading tqdm-4.66.1-py3-none-any.whl (78 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.3/78.3 KB 4.9 MB/s eta 0:00:00
Collecting ansiwrap
  Downloading ansiwrap-0.8.4-py2.py3-none-any.whl (8.5 kB)
Collecting requests
  Downloading requests-2.31.0-py3-none-any.whl (62 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.6/62.6 KB 4.9 MB/s eta 0:00:00
Collecting tenacity
  Downloading tenacity-8.2.3-py3-none-any.whl (24 kB)
Collecting python-dateutil>=2.8.2
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 247.7/247.7 KB 7.9 MB/s eta 0:00:00
Collecting pyzmq>=23.0
  Downloading pyzmq-25.1.1-cp310-cp310-manylinux_2_28_x86_64.whl (1.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 7.6 MB/s eta 0:00:00
Collecting jupyter-core!=5.0.*,>=4.12
  Downloading jupyter_core-5.3.1-py3-none-any.whl (93 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 93.7/93.7 KB 6.6 MB/s eta 0:00:00
Collecting traitlets>=5.3
  Downloading traitlets-5.10.0-py3-none-any.whl (120 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 120.4/120.4 KB 5.3 MB/s eta 0:00:00
Collecting tornado>=6.2
  Downloading tornado-6.3.3-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (427 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 427.7/427.7 KB 7.5 MB/s eta 0:00:00
Collecting platformdirs>=2.5
  Downloading platformdirs-3.10.0-py3-none-any.whl (17 kB)
Collecting jsonschema>=2.6
  Downloading jsonschema-4.19.0-py3-none-any.whl (83 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 83.4/83.4 KB 8.0 MB/s eta 0:00:00
Collecting fastjsonschema
  Downloading fastjsonschema-2.18.0-py3-none-any.whl (23 kB)
Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.8.2->jupyter_client>=8.3.0->-r /home/mabaig/.modular/pkg/packages.modular.com_mojo/scripts/post-install/requirements.txt (line 3)) (1.16.0)
Collecting textwrap3>=0.9.2
  Downloading textwrap3-0.9.2-py2.py3-none-any.whl (12 kB)
Collecting certifi>=2017.4.17
  Downloading certifi-2023.7.22-py3-none-any.whl (158 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 158.3/158.3 KB 6.0 MB/s eta 0:00:00
Collecting charset-normalizer<4,>=2
  Downloading charset_normalizer-3.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (201 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 201.8/201.8 KB 5.6 MB/s eta 0:00:00
Collecting idna<4,>=2.5
  Downloading idna-3.4-py3-none-any.whl (61 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 KB 3.4 MB/s eta 0:00:00
Collecting urllib3<3,>=1.21.1
  Downloading urllib3-2.0.4-py3-none-any.whl (123 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 123.9/123.9 KB 5.8 MB/s eta 0:00:00
Collecting attrs>=22.2.0
  Downloading attrs-23.1.0-py3-none-any.whl (61 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.2/61.2 KB 5.5 MB/s eta 0:00:00
Collecting jsonschema-specifications>=2023.03.6
  Downloading jsonschema_specifications-2023.7.1-py3-none-any.whl (17 kB)
Collecting rpds-py>=0.7.1
  Downloading rpds_py-0.10.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 8.6 MB/s eta 0:00:00
Collecting referencing>=0.28.4
  Downloading referencing-0.30.2-py3-none-any.whl (25 kB)
Installing collected packages: textwrap3, find_libpython, fastjsonschema, urllib3, traitlets, tqdm, tornado, tenacity, rpds-py, pyzmq, python-dateutil, platformdirs, idna, entrypoints, click, charset-normalizer, certifi, attrs, ansiwrap, requests, referencing, jupyter-core, jupyter_client, jsonschema-specifications, jsonschema, nbformat, nbclient, papermill
  WARNING: The script find_libpython is installed in '/home/mabaig/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script tqdm is installed in '/home/mabaig/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script normalizer is installed in '/home/mabaig/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts jupyter, jupyter-migrate and jupyter-troubleshoot are installed in '/home/mabaig/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts jupyter-kernel, jupyter-kernelspec and jupyter-run are installed in '/home/mabaig/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script jsonschema is installed in '/home/mabaig/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script jupyter-trust is installed in '/home/mabaig/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script jupyter-execute is installed in '/home/mabaig/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script papermill is installed in '/home/mabaig/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed ansiwrap-0.8.4 attrs-23.1.0 certifi-2023.7.22 charset-normalizer-3.2.0 click-8.1.7 entrypoints-0.4 fastjsonschema-2.18.0 find_libpython-0.3.0 idna-3.4 jsonschema-4.19.0 jsonschema-specifications-2023.7.1 jupyter-core-5.3.1 jupyter_client-8.3.1 nbclient-0.8.0 nbformat-5.9.2 papermill-2.4.0 platformdirs-3.10.0 python-dateutil-2.8.2 pyzmq-25.1.1 referencing-0.30.2 requests-2.31.0 rpds-py-0.10.3 tenacity-8.2.3 textwrap3-0.9.2 tornado-6.3.3 tqdm-4.66.1 traitlets-5.10.0 urllib3-2.0.4
Testing `MODULAR_HOME=/home/mabaig/.modular`
* `/home/mabaig/.modular/pkg/packages.modular.com_mojo/bin/mojo`...
TEST: `mojo --help`... OK
TEST: `mojo run --help`... OK
TEST: `mojo build test_mandelbrot.mojo`... OK
TEST: `mojo build test_python.mojo`... OK
TEST: `mojo demangle`... OK
TEST: `mojo format`... OK
TEST: `mojo package`... OK
TEST: `mojo test_mandelbrot.mojo`... OK
TEST: `mojo test_python.mojo`... OK
TEST: `mojo repl`... OK
🔥 Mojo installed! 🔥
Now run the following commands if you are using bash:
echo 'export MODULAR_HOME="/home/mabaig/.modular"' >> ~/.bashrc
echo 'export PATH="/home/mabaig/.modular/pkg/packages.modular.com_mojo/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
If you are using ZSH, run the following commands:
echo 'export MODULAR_HOME="/home/mabaig/.modular"' >> ~/.zshrc
echo 'export PATH="/home/mabaig/.modular/pkg/packages.modular.com_mojo/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
Then enter 'mojo' to start the Mojo REPL.
For tool help, enter 'mojo --help'.
For more docs, see https://docs.modular.com/mojo.
mabaig@mabaig-tp:~$

5. Интеграция Ubuntu с VS Code

  • Чтобы сделать процесс еще более простым, вы можете открыть рабочую область Ubuntu непосредственно в VS Code. Просто введите:
mabaig@mabaig-tp:~$ echo 'export MODULAR_HOME="$HOME/.modular"' >> ~/.bashrc
mabaig@mabaig-tp:~$ echo 'export PATH="$MODULAR_HOME/pkg/packages.modular.com_mojo/bin:$PATH"' >> ~/.bashrc
mabaig@mabaig-tp:~$ source ~/.bashrc
mabaig@mabaig-tp:~$ code .
mabaig@mabaig-tp:~$
  • Благодаря этому ваше рабочее пространство Ubuntu теперь доступно через VS Code, предоставляя интегрированную среду для ваших задач разработки.

mabaig@mabaig-tp:~$ echo 'export MODULAR_HOME="$HOME/.modular"' >> ~/.bashrc
mabaig@mabaig-tp:~$ echo 'export PATH="$MODULAR_HOME/pkg/packages.modular.com_mojo/bin:$PATH"' >> ~/.bashrc
mabaig@mabaig-tp:~$ source ~/.bashrc
mabaig@mabaig-tp:~$ code .
mabaig@mabaig-tp:~$

6. Начните свой опыт Mojo

  • Все готово? Давайте сразу приступим к делу! Начните свое путешествие с простой программы «Hello World», чтобы проверить настройку Mojo.

И вот оно! Хотя путешествие по Mojo Windows еще продолжается, это руководство гарантирует, что вам не придется ждать, чтобы погрузиться в действие. Приятного кодирования!