Add MAX/Mojo to a conda project
Although we recommend using Magic to manage your virtual environments and packages for MAX and Mojo, you can also add MAX/Mojo to a conda project.
Here's how to create a new conda environment with MAX/Mojo:
conda create -n max-project -c conda-forge -c https://conda.modular.com/max/ \
python=3.11 max=* -y
Then activate the environment and you'll have access to mojo
:
conda activate max-project
mojo --version
The max
package includes Mojo. There's no separate package for Mojo.
Run a MAX exampleβ
Each example in our MAX repo includes a conda environment.yml
file with the
environment named max-repo
. For example, here's how you can run one of the
MAX inference examples in a conda environment:
git clone https://github.com/modularml/max.git
cd max/examples/inference/bert-python-torchscript
conda activate max-repo
bash run.sh
Run a Mojo exampleβ
Each example in our MAX repo includes a conda environment.yml
file with the
environment named max-repo
. For example, here's how you can run one of the
MAX inference examples in a conda environment:
git clone https://github.com/modularml/mojo.git
cd mojo/examples
conda create -n mojo-repo -c conda-forge -c https://conda.modular.com/max/ \
python=3.11 max=* -y
conda activate mojo-repo
mojo hello_interop.mojo
Hello Mojo π₯!
9
6
3
Hello from Python!
I can even print a numpy array: [1 2 3]
You might encounter issues if you invoke magic
within a conda
virtual
environment. It's best if you don't mix the two tools.
For more information about using conda, see the conda documentation.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!
If you'd like to share more information, please report an issue on GitHub
π What went wrong?