Mac VMEC Installation - hiddenSymmetries/simsopt GitHub Wiki

Instructions for installing VMEC on Mac M3

These instructions were written by Misha Padidar on June 12, 2025. If you have trouble with installing VMEC on Mac, feel free to reach out to the author.

  1. Make a directory to keep everything in,
    mkdir project
    cd project
    
  2. (Optional) Install pyenv with brew. pyenv is a python version manager. Generally, it is recommended to manage your own version of python rather than use the version of python that comes with your computer.
    brew install pyenv
    
    Then follow the pyenv setup instructions on the pyenv github page.
  • Install python 3.10.1. Python 3.10.1 worked during the writing of this document. Typically, you should aim to use a recent version of python, though the installation may not always work with the most recent
    pyenv install 3.10.1
    
  • Set up python 3.10.1 to be the one used in the local directory,
    pyenv local 3.10.1
    
  1. Make a virtual environment,

    python -m venv env
    source env/bin/activate
    

    The venv can be activated with source env/bin/activate.

  2. Install openmppi and some pip packages

    brew install open-mpi
    python -m pip install numpy
    python -m pip install cmake scikit-build ninja f90wrap
    python -m pip install mpi4py
    
  3. (Optional) Install simsopt with the MPI connection.

    python -m pip install simsopt"[MPI]"
    
  4. Install some stuff for working with VMEC,

    brew install gcc (this comes with gfortran)
    brew install scalapack
    brew install netcdf-fortran
    brew install openblas
    

    Also install f90wrap dependency meson-python:

    python -m pip install meson-python
    
  5. clone VMEC2000

    git clone [email protected]:hiddenSymmetries/VMEC2000.git
    cd VMEC2000
    
  6. Modify the cmake_config_file.json to be,

    {
        "cmake_args": [
            "-DCMAKE_C_COMPILER=clang",
            "-DCMAKE_CXX_COMPILER=clang",
            "-DCMAKE_Fortran_COMPILER=mpif90",
            "-DNETCDF_INC_PATH=/opt/homebrew/opt/netcdf-fortran/include",
            "-DNETCDF_LIB_PATH=/opt/homebrew/opt/netcdf-fortran/lib",
            "-DNETCDF_I=/opt/local/include/netcdf.inc"]
    }
    

    Then install VMEC

    python -m pip install . -v
    

    If the install fails, remove the _skbuild directory. Install whatever you need or adjust the cmake_config_file.json and try again. Sometimes, the pip install fails for frustrating reasons, in which case, try to build from source

    python setup.py build_ext
    python setup.py install
    
  7. (Optional) Add the VMEC repository to your PYTHONPATH so that the directory structure is recognized by python. Modify your .zshrc to contain the following line (replacing the path with the relevant one)`,

    export PYTHONPATH="your/project/VMEC2000"
    

    You can always delete this line if you want to delete the repo. This way you will always be able to load VMEC in python.