|
| 1 | +# How to install CellProfiler from source with all plugins on Mac OS |
| 2 | + |
| 3 | +1. **Download and install [Java JDK 11](https://adoptium.net/temurin/releases/?version=11)** |
| 4 | + |
| 5 | + <img src="https://user-images.githubusercontent.com/28116530/184950214-ca9d8d07-ab66-45f2-9a18-fb220bd0a8ec.png" width=500px/> |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + **NOTE**: For M1/M2 Macs, which use the ARM 64-bit architecture, use [this link](https://www.azul.com/downloads/?version=java-11-lts&os=macos&architecture=arm-64-bit&package=jdk) to get Java 11. |
| 10 | + |
| 11 | + <img src = "https://user-images.githubusercontent.com/28116530/184956441-26ded1ac-0f8f-4bc2-93d9-e6c8554a0018.png" width=500px/> |
| 12 | + |
| 13 | + |
| 14 | + After you download the file, open the installer and proceed through the steps to install Java 11. |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | +2. **Download and install or update conda** |
| 20 | + |
| 21 | + For beginners, we recommend you use Anaconda Navigator since it is more beginner-friendly, but you can also use miniconda. [Download Anaconda](https://www.anaconda.com/products/distribution) from the website and install. |
| 22 | + |
| 23 | + **NOTE**: if you already have conda, you can get the command to update conda by typing `conda update` on your command line. The command will generally look like: |
| 24 | + |
| 25 | + `conda update --prefix /Users/USERNAME/opt/anaconda3 anaconda` |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +3. **Clone the CellProfiler-plugins Repo** |
| 30 | + |
| 31 | + Download a copy of (aka "clone") the CellProfiler-plugins repo from [here](https://github.com/CellProfiler/CellProfiler-plugins.git). You can download the whole repo by cloning it with git or simply clicking the green **Code** button on [the repo page](https://github.com/CellProfiler/CellProfiler-plugins.git) and selecting **Download ZIP** (see below). |
| 32 | + |
| 33 | + <img src="images/Install_environment_instructions_windows/2022-06-02T21-39-05.png" width="500"/> |
| 34 | + |
| 35 | + You can also use git or GitHub Desktop to clone the repo if you prefer. |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +4. **Create the environment from the .yml file** |
| 40 | + |
| 41 | + Open Anaconda Navigator and select the **Environments** tab on the left. We recommend you create the environment from the command line. To do this, Select the play button next to your base (root) environment and select **Open Terminal**: |
| 42 | + |
| 43 | + <img src="images/Install_environment_instructions_windows/2022-06-02T21-11-49.png" width="500"/> |
| 44 | + |
| 45 | + A black box should pop up with a blinking cursor. This is your terminal. You now need to navigate to where the **cellprofiler_plugins_mac.yml** file is inside of the CellProfiler-plugins folder you downloaded in the last step. This file is in the `Instructions` subfolder. Here is how we recommend you do this: |
| 46 | + 1) In Finder, open the folder you downloaded in the previous step (usually called "CellProfiler-plugins-master") |
| 47 | + 2) There should be a folder called **Instructions**. Right click or ctrl+click that folder. Then hold down the option key (or Alt) on your keyboard. An option to **Copy "Instructions" as Pathname** should appear. Select this option. (see below) |
| 48 | + |
| 49 | + <img width="509" alt="image" src="https://user-images.githubusercontent.com/28116530/184949743-901ada5e-dbe5-40d6-99c2-ad0877bddc31.png"> |
| 50 | + |
| 51 | + |
| 52 | + 3) Go back to your terminal and type `cd PATH_TO_FOLDER` where `PATH_TO_FOLDER` is the address you copied in the previous step. Press Enter. |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + Now that you're in the right place, copy and paste this command into the terminal and press Enter. |
| 57 | + ``` |
| 58 | + conda env create -f CellProfiler_plugins_mac.yml |
| 59 | + ``` |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + 5. **Activate your environment** |
| 64 | + |
| 65 | + In your terminal, enter `conda activate CellProfiler_plugins` to activate your environment |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + 6. **Verify that cellprofiler is installed correctly by running it from the command line.** |
| 71 | + |
| 72 | + In your terminal, type in `pythonw -m cellprofiler` and hit Enter. this will open CellProfiler or will give you an error message. |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + 7. **Install other packages for other plugins** |
| 77 | + |
| 78 | + Certain packages cannot easily installed when importing the environment. |
| 79 | + |
| 80 | + For StarDist: In terminal with your environment activated, enter: |
| 81 | + ``` |
| 82 | + pip install stardist csbdeep --no-deps |
| 83 | + ``` |
| 84 | + |
| 85 | + |
| 86 | + If you would like to use the omnipose models in cellpose, ensure you have cellpose 1.0.2 (you should by default if you've used the CellProfiler_plugins_mac.yml file to generate the environment) and enter on the command line (in your activated environment): |
| 87 | +
|
| 88 | + ``` |
| 89 | + pip install omnipose |
| 90 | + ``` |
| 91 | + |
| 92 | + |
| 93 | +
|
| 94 | +
|
| 95 | + 8. **Connect CellProfiler and the plugins repo** |
| 96 | +
|
| 97 | + With your environment active, type `pythonw -m cellprofiler` in terminal to open CellProfiler if it is not open already. |
| 98 | +
|
| 99 | + * In CellProfiler, go to **File** then **Preferences...** |
| 100 | + * Scroll down and look for "CellProfiler Plugins Directory" on the left. |
| 101 | + * Select the **Browse** button and choose the folder where you extracted the CellProfiler plugins files. It is probably called "CellProfiler-plugins-master" unless you have renamed it. |
| 102 | + * Select **Save** at the bottom of the Preferences window |
| 103 | + * Close CellProfiler and reopen it by typing `pythonw -m cellprofiler` on the command line |
| 104 | +
|
| 105 | +
|
| 106 | + **NOTE**: You might get a warning like this: |
| 107 | + ``` |
| 108 | + W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found |
| 109 | + 2022-05-26 20:24:21.906286: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. |
| 110 | + ``` |
| 111 | + If you don't have a GPU, this is not a problem. If you do, your configuration is incorrect and you need to try reinstalling drivers and the correct version of CUDA for your system. |
| 112 | +
|
| 113 | + |
| 114 | +
|
| 115 | + 9. **Verify that the installation worked** |
| 116 | +
|
| 117 | + Add a module to your pipeline by hitting the **+** button in the pipeline panel (bottom left) |
| 118 | +
|
| 119 | + In the "Add Modules" window that pops up, type "run" into the search bar. You should be able to see plugins like RunCellpose and RunStarDist if the installation was successful: |
| 120 | +  |
| 121 | +
|
| 122 | + --- |
| 123 | +
|
| 124 | +
|
| 125 | +## Common errors |
| 126 | +
|
| 127 | +1. My wheels are failing to build |
| 128 | +
|
| 129 | +- If you get a message like "ERROR: Failed building wheel for pyzmq" this usually means that you do not have pyzmq installed. Try to reinstall pyzmq. |
| 130 | +
|
| 131 | +2. Java virtual machine cannot be found |
| 132 | +
|
| 133 | +- If you're getting errors about Java, it means that java is not being configured properly on your system. |
| 134 | +- Make sure you have installed The Java Development Kit 11 [here](https://adoptopenjdk.net/). Note that newer versions may not work. |
| 135 | +- Make sure you've added environment variables at the **System** level and not at the **User** level. |
| 136 | +``` |
| 137 | +brew install java |
| 138 | + |
| 139 | +# For the system Java wrappers to find this JDK, symlink it with |
| 140 | +sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk |
| 141 | + |
| 142 | +# Set version in zshrc |
| 143 | +echo export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) >> ~/.zshrc |
| 144 | +source ~/.zshrc |
| 145 | +``` |
| 146 | +
|
| 147 | +3. Installing pyzmq failed |
| 148 | +
|
| 149 | +- You might get an error when trying to install pyzmq. Something like |
| 150 | +``` |
| 151 | +ERROR: Command errored out with exit status 1: |
| 152 | +``` |
| 153 | +And earlier in the traceback: |
| 154 | +``` |
| 155 | +Fatal: Cython-generated file 'zmq\backend\cython\_device.c' not found. |
| 156 | + Cython >= 0.20 is required to compile pyzmq from a development branch. |
| 157 | + Please install Cython or download a release package of pyzmq. |
| 158 | +``` |
| 159 | +
|
| 160 | + To fix this, `conda install cython` |
| 161 | +
|
| 162 | +
|
| 163 | +## Installation instructions for CellProfiler, CellProfiler plugins and CellPose in a conda environment on Apple silicon (eg M1). |
| 164 | +
|
| 165 | +1. **Install brew** |
| 166 | + ``` |
| 167 | + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
| 168 | + ``` |
| 169 | +
|
| 170 | +2. **Update brew** |
| 171 | + ``` |
| 172 | + brew update |
| 173 | + ``` |
| 174 | + |
| 175 | +3. **Install Java** |
| 176 | + ``` |
| 177 | + brew install java |
| 178 | + ``` |
| 179 | +
|
| 180 | +4. **For the system Java wrappers to find this JDK and symlink it** |
| 181 | + ``` |
| 182 | + sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk |
| 183 | + ``` |
| 184 | +
|
| 185 | +5. **Set version in .zshrc** |
| 186 | + ``` |
| 187 | + echo export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) >> ~/.zshrc |
| 188 | + source ~/.zshrc |
| 189 | + ``` |
| 190 | +
|
| 191 | +6. **Brew install package requirements** |
| 192 | + ``` |
| 193 | + brew install freetype mysql git |
| 194 | + ``` |
| 195 | +
|
| 196 | +7. **Direct to brew openssl** |
| 197 | + ``` |
| 198 | + export LDFLAGS="-L$(brew --prefix)/opt/openssl/lib" |
| 199 | + ``` |
| 200 | +
|
| 201 | +8. **Install hdf5** |
| 202 | + ``` |
| 203 | + brew install hdf5@1.12 |
| 204 | + ``` |
| 205 | +
|
| 206 | +9. **Make sure to get the version directory correct for the version installed. Find with `ls /opt/homebrew/Cellar/hdf5/`** |
| 207 | + ``` |
| 208 | + export HDF5_DIR=/opt/homebrew/Cellar/hdf5/1.12.1_1/ |
| 209 | + ``` |
| 210 | +10. **Create a folder and download cellprofiler-plugins** |
| 211 | +
|
| 212 | + ``` |
| 213 | + mkdir cp_plugins |
| 214 | + cd cp_plugins |
| 215 | + git clone https://github.com/CellProfiler/CellProfiler-plugins |
| 216 | + ``` |
| 217 | +
|
| 218 | +11. **Download and install miniconda** |
| 219 | +
|
| 220 | + ``` |
| 221 | + wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh -O ~/miniconda.sh |
| 222 | + ``` |
| 223 | +
|
| 224 | +
|
| 225 | +12. **Create a conda `.yml` file** |
| 226 | + In a text editor, paste the following test and save it as `cellprofiler_plugins_macM1.yml`: |
| 227 | + ``` |
| 228 | + name: cpcellpose |
| 229 | +
|
| 230 | + channels: |
| 231 | + - conda-forge |
| 232 | + - anaconda |
| 233 | + - bioconda |
| 234 | + - defaults |
| 235 | + - apple |
| 236 | +
|
| 237 | + dependencies: |
| 238 | + - python=3.8 |
| 239 | + - pip |
| 240 | + - h5py |
| 241 | + - mysqlclient |
| 242 | + - imagecodecs |
| 243 | + - python.app |
| 244 | + - pandas |
| 245 | + - pip: |
| 246 | + - cellpose |
| 247 | + - attrdict |
| 248 | + - sip==5.5.0 |
| 249 | + - boto3>=1.12.28 |
| 250 | + - centrosome==1.2.1 |
| 251 | + - docutils==0.15.2 |
| 252 | + - h5py~=3.6.0 |
| 253 | + - imageio>=2.5 |
| 254 | + - inflect>=2.1 |
| 255 | + - Jinja2>=2.11.2 |
| 256 | + - joblib>=0.13 |
| 257 | + - mahotas>=1.4 |
| 258 | + - matplotlib==3.1.3 |
| 259 | + - mysqlclient==1.4.6 |
| 260 | + - numpy>=1.20.1 |
| 261 | + - Pillow>=7.1.0 |
| 262 | + - prokaryote==2.4.4 |
| 263 | + - python-bioformats==4.0.6 |
| 264 | + - python-javabridge==4.0.3 |
| 265 | + - pyzmq~=22.3 |
| 266 | + - sentry-sdk==0.18.0 |
| 267 | + - requests>=2.22 |
| 268 | + - scikit-image>=0.17.2 |
| 269 | + - scikit-learn>=0.20 |
| 270 | + - scipy>=1.4.1 |
| 271 | + - six |
| 272 | + - tifffile<2022.4.22 |
| 273 | + - wxPython==4.2.0 |
| 274 | + ``` |
| 275 | +
|
| 276 | +
|
| 277 | +13. **Create a conda environment using the cellprofiler_plugins_macM1.yml file** |
| 278 | +
|
| 279 | + At this stage, your folder/file structure should look like this: |
| 280 | +
|
| 281 | + ``` |
| 282 | + ├── cp_plugins |
| 283 | + ├── CellProfiler-plugins |
| 284 | + └── cellprofiler_plugins_macM1.yml |
| 285 | + ``` |
| 286 | +
|
| 287 | + In the terminal, make sure you are in the `cp_plugins` folder mentioned above (run `cd cp_plugins` to get there). |
| 288 | +
|
| 289 | + ``` |
| 290 | + conda env create -n cp_plugins --file cellprofiler_plugins_macM1.yml |
| 291 | + ``` |
| 292 | +
|
| 293 | +14. **Activate the conda environment** |
| 294 | +
|
| 295 | + ``` |
| 296 | + conda activate cp_plugins |
| 297 | + ``` |
| 298 | +
|
| 299 | +15. **Install CellProfiler and CellProfiler-core** |
| 300 | + ``` |
| 301 | + pip install cellprofiler-core |
| 302 | +
|
| 303 | + # We install CellProfiler with no dependencies here since we installed them with the conda yml file |
| 304 | + # This allows us to have some dependencies for M1 that are not the default for CellProfiler (eg wxPython) |
| 305 | + git clone https://github.com/CellProfiler/CellProfiler |
| 306 | +
|
| 307 | + pip install --no-deps cellprofiler |
| 308 | + ``` |
| 309 | +
|
| 310 | +16. **Open CellProfiler** |
| 311 | + ``` |
| 312 | + pythonw -m cellprofiler |
| 313 | + ``` |
| 314 | +
|
| 315 | +17. **Connect CellProfiler with the plugins folder** |
| 316 | +
|
| 317 | + 1. In CellProfiler, go to `File` then `Preferences...` |
| 318 | + 2. Scroll down and look for `CellProfiler Plugins Directory` on the left. |
| 319 | + 3. Select the Browse button and choose the folder where you extracted the CellProfiler plugins files. It is probably called `CellProfiler-plugins` unless you have renamed it. |
| 320 | + 4. Select Save at the bottom of the Preferences window |
| 321 | + 5. Close CellProfiler and reopen it by typing `pythonw -m cellprofiler` in the command line |
| 322 | +
|
| 323 | +
|
| 324 | +### Resolving dependencies conflicts |
| 325 | +
|
| 326 | + There can be some strange dependency conflicts that can arise with python-javabridge. In the terminal with your environment activate, enter: |
| 327 | + ``` |
| 328 | + pip uninstall -y centrosome python-javabridge |
| 329 | + pip install --no-cache-dir --no-deps --no-build-isolation python-javabridge centrosome |
| 330 | + pip uninstall matplotlib -y |
| 331 | + pip install matplotlib==3.2 |
| 332 | + pip uninstall mahotas -y |
| 333 | + pip install mahotas |
| 334 | + ``` |
| 335 | +
|
| 336 | + The latest version of CellProfiler available on github removes the python-javabridge requirement and instead uses ScyJava. |
| 337 | +
|
| 338 | +### Test your installation |
| 339 | +
|
| 340 | +Add a module to your pipeline by hitting the **+** button in the pipeline panel (bottom left) |
| 341 | +
|
| 342 | +In the "Add Modules" window that pops up, type "run" into the search bar. You should be able to see plugins like RunCellpose and RunStarDist if the installation was successful: |
| 343 | + |
0 commit comments