Source installation (Ubuntu 16.04 LTS) - CellProfiler/CellProfiler GitHub Wiki

4.0.0

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt -y upgrade
sudo apt install -y python3.8-dev python3.8-distutils python3-pip openjdk-8-jdk-headless libmysqlclient-dev libnotify-dev libsdl2-dev
#If and only if you are building your wxPython not from a wheel, you may need the following libraries:
#Otherwise, skip to the "export" steps
sudo apt-get install -y \
                freeglut3 \
                freeglut3-dev \
                libgl1-mesa-dev \
                libglu1-mesa-dev \
                libgstreamer-plugins-base1.0-dev \
                libgtk-3-dev \
                libgtk2.0-dev \
                libjpeg-dev \
                libnotify-dev \
                libsdl2-dev \
                libsm-dev \
                libtiff-dev \
                libwebkitgtk-3.0-dev \
                libwebkitgtk-dev \
                libxtst-dev

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$PATH:/home/ubuntu/.local/bin

sudo apt remove -y python3-pip
wget https://bootstrap.pypa.io/get-pip.py
sudo python3.8 get-pip.py
rm get-pip.py
python3.8 -m pip install numpy
wget https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04/wxPython-4.1.0-cp38-cp38-linux_x86_64.whl
python3.8 -m pip install wxPython-4.1.0-cp38-cp38-linux_x86_64.whl
python3.8 -m pip install cellprofiler

3.1.9

This procedure has been confirmed to work on a clean install of Ubuntu 16.04. First install system prerequisites for CellProfiler with apt. You will have to confirm the list of installed packages:

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install \
    build-essential    \
    cython             \
    git                \
    libmysqlclient-dev \
    libhdf5-dev        \
    libxml2-dev        \
    libxslt1-dev       \
    openjdk-8-jdk      \
    python-dev         \
    python-pip         \
    python-h5py        \
    python-matplotlib  \
    python-mysqldb     \
    python-scipy       \
    python-numpy       \
    python-pytest      \
    python-vigra       \
    python-wxgtk3.0    \
    python-zmq

Checkout the CellProfiler sources:

$ git clone https://github.com/CellProfiler/CellProfiler.git
$ cd CellProfiler

Its possible to use a specific branch or tag of CellProfiler. The latest stable version is in branch 'stable', or specific versions can be found in tags. I.e. to use the latest stable, use:

$ git checkout stable

or to use version 3.1.9, use:

$ git checkout v3.1.9

Finally when you have checked out the version you want, you are ready to start the compile / install of python dependencies.

$ sudo pip install .

Alternatively, you can install CellProfiler into your home directory (preferred):

$ pip install --user --editable .

If you get an error ImportError: No module named Cython.Build run

pip install --upgrade cython

When using pip with --user, it will install CellProfiler and its dependencies in the platform-specific user install directory. It is possible to get the install directory from Python itself using the site module. This may be something like $HOME/.local, so the packages may be installed in $HOME/.local/bin.

$ python -m site --user-base

Add this directory to your PATH environment variable to start pip-installed packages:

$ export PATH="$HOME/.local/bin:$PATH"

Finally,

$ cellprofiler

will run CellProfiler.

Issues and Workarounds

There is an issue in 2.2.0 that breaks the java bindings in prokaryote. To work around the issue, its sufficient to re-install prokaryote from the CellProfiler source directory:

pip uninstall prokaryote
pip install prokaryote

If you get this error:

...
File "/tmp/easy_install-YiEaoP/javabridge-1.0.15/setup.py", line 137, in ext_modules
  ]
File "/usr/lib/python2.7/posixpath.py", line 122, in dirname
  i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'

Be sure to use java 8:

sudo update-alternatives --config java

Uninstalling CellProfiler

pip uninstall cellprofiler