Skip to content

Installation issue on M3 Macbook #548

Closed

Description

@songaeun

Hello,

I'm struggling to install brainiak on M3 Macbook. The conda option didn't work, throwing an error like:

Channels:
 - brainiak
 - defaults
 - conda-forge
Platform: osx-arm64
Collecting package metadata (repodata.json): done
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  - brainiak

Current channels:

  - https://conda.anaconda.org/brainiak
  - defaults
  - https://conda.anaconda.org/conda-forge
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

The pip option didn't work either. I followed the steps listed here (https://brainiak.org/docs/installation.html#macos) for the prerequisite. All seemed working until the line of python3 -m pip install -U pip

The error was like:

error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try brew install
    xyz, where xyz is the package you are trying to
    install.
    
    If you wish to install a Python library that isn't in Homebrew,
    use a virtual environment:
    
    python3 -m venv path/to/venv
    source path/to/venv/bin/activate
    python3 -m pip install xyz
    
    If you wish to install a Python application that isn't in Homebrew,
    it may be easiest to use 'pipx install xyz', which will manage a
    virtual environment for you. You can install pipx with
    
    brew install pipx
    
    You may restore the old behavior of pip by passing
    the '--break-system-packages' flag to pip, or by adding
    'break-system-packages = true' to your pip.conf file. The latter
    will permanently disable this error.
    
    If you disable this error, we STRONGLY recommend that you additionally
    pass the '--user' flag to pip, or set 'user = true' in your pip.conf
    file. Failure to do this can result in a broken Homebrew installation.
    
    Read more about this behavior here: <https://peps.python.org/pep-0668/>

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

Any suggestion?

Activity

  1. poldrack commented on Nov 23, 2024

    @poldrack

    same problem - bumping this.

  2. songaeun commented on Nov 24, 2024

    @songaeun
    Author

    I ended up installing Brainiak by directly cloning its GitHub repository. I’m sharing my solution here in case it helps other users.

    Seems like the default setting of my M3 MacBook was slightly different from what the tutorial assumed. So I checked and adjusted several things:

    1. Checked the shell type my mac is on.
    2. Located the correct path to llvm installed on my mac.
    3. Downgraded python from 3.13 to 3.11 or lower.
    4. Cloned and installed the brainiak GitHub repository.

    The code I used:

    # Check the default shell
    echo $SHELL 
    # It was zsh, not bash. So clang path had to be added to $HOME/.zshrc, not $HOME/.bash_profile 
    
    # Check where llvm was installed
    brew —prefix llvm 
    # It was /opt/homebrew/opt/llvm, not /usr/local/opt/llvm/ for some reason..
    
    # Add clang paths
    echo 'export CC=/opt/homebrew/opt/llvm/bin/clang' >> $HOME/.zshrc 
    echo 'export CXX=/opt/homebrew/opt/llvm/bin/clang++' >> $HOME/.zshrc 
    export LDFLAGS="-L/opt/homebrew/opt/llvm/lib "\
    "-Wl,-rpath,/opt/homebrew/opt/llvm/lib $LDFLAGS" >> $HOME/.zshrc
    export CPPFLAGS="-I/opt/homebrew/opt/llvm/include $CPPFLAGS" >> $HOME/.zshrc
    export PATH="/opt/homebrew/opt/llvm/bin:$PATH" >> $HOME/.zshrc
    source ~/.zshrc
    
    # Verify if it’s correctly added 
    echo $CC
    echo $CXX
    
    # downgrade python
    brew install python@3.11 
    # my default python was 3.13, which seemed incompatible with one of the libraries (theano) Brainiak uses.
    
    # Create and activate a python virtual environment
    python3.11 -m venv myenv
    source myenv/bin/activate
    
    # install Brainiak
    cd myworkingdirectory
    git clone https://github.com/brainiak/brainiak.git 
    cd brainiak 
    pip install -e .
    
    # checkif successfully installed
    pip show brainiak
    
    

    I’m not entirely sure if this is efficient or recommendable approach, but it worked for me. But hope this helps anyone facing similar issues.

  3. poldrack commented on Nov 24, 2024

    @poldrack

    thanks! this worked for me as well - I used micromamba to set up the environment and had to change the pyproject.toml to deal with a python minor version mismatch:

    requires-python = "<=3.11.10"
    

    but otherwise seems to import fine now.

  4. mihaic commented on Nov 25, 2024

    @mihaic
    Member

    @songaeun, thank you very much for posting your step-by-step guide. @poldrack, thank you for confirming the steps are working.

    @davidt0x has recently revamped BrainIAK packaging in an amazing PR. Now we only need to get the package publishing going and installation should become much smoother.

  5. davidt0x commented on Dec 9, 2024

    @davidt0x
    Contributor

    Hi @songaeun and @poldrack, we have a pre-view release up now for brainiak with wheels for ARM macs. It should be installable with something like:

    pip install brainiak==0.12a5

    in a fresh python environment (Python 3.9 - 3.12). It shouldn't require setting up clang and such. If you have issues with mpi4py wheels then I think you can get them on macos like this:

    python -m pip install mpi4py -i https://pypi.anaconda.org/mpi4py/simple (see here)

    If you need to actually use the MPI stuff in brainiak then you need to install an mpi implementation, either mpich or openmpi from brew\macports

    If you prefer conda, there is also package (that includes mpi4py and mpich) that you can install with:

    conda install -c brainiak -c conda-forge brainiak==0.12a5

    If either of you have the time it would be nice to know if these solutions work for you. Also, thanks again for posting your previous solutions.

  6. songaeun commented on Dec 10, 2024

    @songaeun
    Author

    Hi @davidt0x, both pip and conda install commands work on my m3 Macbook. Thank you so much for releasing these options!

  7. davidt0x commented on Dec 10, 2024

    @davidt0x
    Contributor

    thanks for the quick feedback @songaeun!

  8. mihaic commented on Jan 9, 2025

    @mihaic
    Member

    The new BrainIAK v0.12 release supports M3. Thank you for your help with testing, @songaeun!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions