install mojo @(wsl2 + ubuntu22.04.2) 20230913

发布时间 2023-09-13 12:24:14作者: 喜欢六月的雪

Microsoft Store install wsl + ubuntu22.04.2
CMD/PowerShell (as admin): wsl --set-default-version 2 //switch wsl ver, default is wsl 1
Open the ubuntu terminal, and waiting … set the password

wsl2ubuntu

sudo passwd root

//wsl2ubuntu@PCname:~$

sudo apt update
sudo apt upgrade -y

sudo apt install build-essential libssl-dev libffi-dev python3-dev -y

sudo apt install python3-pip python3.10-venv -y
python3 -m venv 01-env

//
wsl2ubuntu@PCname:~$ source 01-env/bin/activate
(01-env) wsl2ubuntu@PCname:~$ deactivate /// exit env: deactivate
wsl2ubuntu@PCname:~$
https://docs.python.org/3.10/tutorial/
//

mkdir mojo

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

cd mojo
source ~/01-env/bin/activate
//(01-env) wsl2ubuntu@PCname:~$

curl https://get.modular.com |
MODULAR_AUTH=mut_<goto https://developer.modular.com/download get this key>
sh -

//
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.
//

// reinstall or 'modular install mojo' fail: modular clean
modular install mojo

//
? Mojo installed! ?

Now run the following commands if you are using bash:

echo 'export MODULAR_HOME="/home/wsl2ubuntu/mojo/.modular"' >> ~/.bashrc
echo 'export PATH="/home/wsl2ubuntu/mojo/.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/wsl2ubuntu/mojo/.modular"' >> ~/.zshrc
echo 'export PATH="/home/wsl2ubuntu/mojo/.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.

(01-env) wsl2ubuntu@PCname:~/mojo$ pwd
/home/wsl2ubuntu/mojo
(01-env) wsl2ubuntu@PCname:~/mojo$ ls -a
. .. .modular
(01-env) wsl2ubuntu@PCname:~/mojo$ ls ~/ -a
. .bash_logout .cache .motd_shown .python_history 01-env
.. .bashrc .local .profile .sudo_as_admin_successful mojo
//