这两天收到了mojo的邮件,说是支持mac系统了,不过只支持arm芯片,还不支持interl芯片的,刚好我的M1就是受支持的,赶紧第一时间去安装尝尝鲜。
因为我的电脑是从intel版本的系统迁移过来的,所以经常遇到各种问题,像这次我就遇到了问题没能解决,在经过一两次失败之后,今天下午下定决定一定要安装上mojo。于是就有了这篇博客记录。下面我来说一下怎么安装上的:
在终端下安装,终端是勾上了“使用Rosetta打开”的,执行以下命令:
curl https://get.modular.com | sh - && \
modular auth mut_d2fc41f5d81f46a6a8c242f8e572f9d7
报以下的错误:
Sorry, modular is not currently supported on Intel based Macs. Please visit https://www.modular.com/mojo to learn about supported platforms. You can also build and run a Mojo container by following instructions at https://github.com/modularml/mojo
按报错应该是说不支持intel芯片的版本,那应该就是勾上“使用Rosetta打开”就是相当于intel芯片的版本。于是我把这个勾选去掉,再继续执行
curl https://get.modular.com | sh - && \
modular auth mut_d2fc41f5d81f46a6a8c242f8e572f9d7
然后报错换了:
Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
Please create a new installation in /opt/homebrew using one of the
"Alternative Installs" from:
https://docs.brew.sh/Installation
You can migrate your previously installed formula list with:
brew bundle dump
在网上查到一个方法是说执行以下命令:
bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
于是执行之后看一下最后的提示:
Warning: /opt/homebrew/bin is not in your PATH.
Instructions on how to configure your shell for Homebrew
can be found in the 'Next steps' section below.
=> Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/ydb/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
- Run brew help to get started
- Further documentation:
https://docs.brew.sh
按提示在命令行中执行:
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/ydb/.zprofileeval "$(/opt/homebrew/bin/brew shellenv)"
回车之后再去安装,竟然神奇地好了。可以正常安装了
继续执行:
modular install mojo
输出安装成功提示:
🔥 Mojo installed! 🔥
Mojo's Python virtual environment created at /Users/ydb/.modular/pkg/packages.modular.com_mojo/venv
Now run the following commands if you are using bash:
echo 'export MODULAR_HOME="/Users/ydb/.modular"' >> ~/.bashrc
echo 'export PATH="/Users/ydb/.modular/pkg/packages.modular.com_mojo/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
If you are using ZSH, run the following commands:
echo 'export MODULAR_HOME="/Users/ydb/.modular"' >> ~/.zshrc
echo 'export PATH="/Users/ydb/.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.
再按提示执行:
echo 'export MODULAR_HOME="/Users/ydb/.modular"' >> ~/.zshrc
echo 'export PATH="/Users/ydb/.modular/pkg/packages.modular.com_mojo/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
然后就测试
mojo --help
最后出来安装成功之后的提示。到此就成功安装上了,希望这个经验能帮到遇到相同问题的朋友,遇到问题不要无脑复制命令执行,看一下执行命令后的提示,按提示操作一般能解决问题。