Installation of CellProfiler 4 from source on M1 Macs - CellProfiler/CellProfiler GitHub Wiki

Below are two sets of installation instructions for installation of CellProfiler from source on Macs using the new Apple M1 processor.

  1. Install homebrew Python
  2. Install CellProfiler inside a conda environment
    • For less conflict problems, it is recommended to follow the conda installation

Brew Python installation

  1. Install brew

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  2. Update brew

    brew update
    
  3. Install python 3.8

    brew install [email protected]
    echo export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH" >> ~/.zshrc
    
  4. Install Java

    brew install java
    
  5. For the system Java wrappers to find this JDK, symlink it with

    sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
    
  6. Set version in zshrc

    echo export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) >> ~/.zshrc
    source ~/.zshrc
    
  7. Brew install the packages req

    brew install freetype mysql
    
  8. Direct to brew openssl

    export LDFLAGS="-L$(brew --prefix)/opt/openssl/lib"
    
  9. Install hdf5

    brew install [email protected]
    
  10. Make sure to get the version directory correct for the version installed. Find with ls /opt/homebrew/Cellar/hdf5/

    export HDF5_DIR=/opt/homebrew/Cellar/hdf5/1.12.1_1/
    
  11. Install wxPython dev build (4.1.2)

    1. Download dev build of wxPython here: https://wxpython.org/Phoenix/snapshot-builds/
    2. Download the latest build with the filename format: wxPython-4.1.2a1.devXXXX+XXXXXXXX.tar.gz
    • Ignore the .whl files
    1. Then, extract wxPython and navigate into the wxPython folder. Install with:
      • wxPython install can take a while
      • attrdict and sip are required to build wxPython
    pip3 install attrdict sip==5.5.0
    pip3 install .
    
  12. Install CellProfiler and CellProfiler-core from source

    git clone https://github.com/CellProfiler/core
    cd core
    pip3 install .
    
    git clone https://github.com/CellProfiler/CellProfiler
    cd CellProfiler
    
  13. Edit CellProfiler setup.py and comment out the wxPython requirement since we're using a different build

    install_requires=[
    # "cellprofiler-core==4.2.1"
    ...
    "scipy>=1.4.1",
    "six",
    # "wxPython==4.1.0",
    ...
    
  14. From inside the CellProfiler directory, install with

    pip3 install -e .
    
  15. In the CellProfiler directory, start CellProfiler with:

    python3 -m cellprofiler
    

Conda installation

  1. Install java and set up

    brew install java
    
    # For the system Java wrappers to find this JDK, symlink it with
    sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
    
    # Set version in zshrc
    echo export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) >> ~/.zshrc
    source ~/.zshrc
    
  2. Create a Python3.8 environment with conda

    conda create --name cellprofiler python=3.8
    
  3. Activate the conda environment

    conda activate cellprofiler
    
  4. Install wxPython dev build (4.1.2)

    1. Download dev build of wxPython here: https://wxpython.org/Phoenix/snapshot-builds/
      1. wxPython 4.1.2 is not currently available through pip
    2. Download the latest build with the filename format: wxPython-4.1.2a1.devXXXX+XXXXXXXX.tar.gz
    • Ignore the .whl files
    1. Then, extract wxPython and navigate into the wxPython folder. Install with:
    • wxPython install can take a while
    • attrdict and sip are required to build wxPython
    pip3 install attrdict sip==5.5.0
    pip3 install .
    
  5. Clone and install CellProfiler-core

    git clone https://github.com/CellProfiler/core
    pip install -e ./core
    
  6. Clone CellProfiler

    git clone https://github.com/CellProfiler/CellProfiler
    
  7. Modify the setup.py in the cloned CellProfiler repo.

    • Comment out cellprofiler-core and wxpython from the install_requires section, since we are installing our own versions from source:
    ...
    "boto3>=1.12.28",
    # "cellprofiler-core==4.2.1",
    "centrosome==1.2.0",
    ...
    "six",
    # "wxPython==4.1.0",
    
  8. Install CellProfiler

    pip install -e ./CellProfiler
    
  9. Install additional dependencies

    # python.app for pythonw
    conda install java h5py mysqlclient python.app  
    
  10. Open CellProfiler

    • Execute this command from within the cloned CellProfiler repo (get there with cd CellProfiler)
    pythonw -m cellprofiler