SchmollerLab / Cell_ACDC

A Python GUI-based framework for segmentation, tracking and cell cycle annotations of microscopy data
BSD 3-Clause "New" or "Revised" License
124 stars 20 forks source link

Could not install on macOS 10.14.6 #530

Closed jacobmhkim closed 1 week ago

jacobmhkim commented 1 week ago

Description:

Tried to install cell acdc on macos 10.14.6. During pip install stage, received this error:

`Downloading six-1.16.0-py2.py3-none-any.whl (11 kB) Building wheels for collected packages: opencv-python-headless Building wheel for opencv-python-headless (pyproject.toml) ... error error: subprocess-exited-with-error

× Building wheel for opencv-python-headless (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [84 lines of output]

  --------------------------------------------------------------------------------
  -- Trying 'Ninja' generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.Not searching for unused variables given on the command line.

  -- Configuring incomplete, errors occurred!
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying 'Ninja' generator - failure
  --------------------------------------------------------------------------------

  --------------------------------------------------------------------------------
  -- Trying 'Unix Makefiles' generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  Not searching for unused variables given on the command line.
  -- The C compiler identification is unknown
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - failed
  -- Check for working C compiler: /usr/bin/cc
  -- Check for working C compiler: /usr/bin/cc - broken
  CMake Error at /private/var/folders/n0/y06cp9mx3s337p18h34s6lxw0000gp/T/pip-build-env-4y3vda9o/overlay/lib/python3.10/site-packages/cmake/data/share/cmake-3.30/Modules/CMakeTestCCompiler.cmake:67 (message):
    The C compiler

      "/usr/bin/cc"

    is not able to compile a simple test program.

    It fails with the following output:

      Change Dir: '/private/var/folders/n0/y06cp9mx3s337p18h34s6lxw0000gp/T/pip-install-yhanh8ka/opencv-python-headless_baa1a604e81e4c19a20823886af04044/_cmake_test_compile/build/CMakeFiles/CMakeScratch/TryCompile-tpT8gH'

      Run Build Command(s): /private/var/folders/n0/y06cp9mx3s337p18h34s6lxw0000gp/T/pip-build-env-4y3vda9o/overlay/lib/python3.10/site-packages/cmake/data/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_205f2/fast
      xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

    CMake will not be able to correctly generate this project.
  Call Stack (most recent call first):
    CMakeLists.txt:3 (ENABLE_LANGUAGE)

  -- Configuring incomplete, errors occurred!
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying 'Unix Makefiles' generator - failure
  --------------------------------------------------------------------------------

                  ********************************************************************************
                  scikit-build could not get a working generator for your system. Aborting build.

                  Building MacOSX wheels for Python 3.10 requires XCode.
  Get it here:

    https://developer.apple.com/xcode/

                  ********************************************************************************
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for opencv-python-headless Failed to build opencv-python-headless ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (opencv-python-headless)`

Seems to require xcode, which requires a macos 14 to install.

Way to reproduce:

No response

(Optional) Link to data to reproduce error:

No response

Terminal output:

No response

Log file:

No response

Version information:

No response

ElpadoCan commented 1 week ago

Hi Jacob, unfortunately, that looks like an error with the package opencv-python-headless and it sounds like they stopped supporting macOS 10.14.

However, I would still try something. Can you try from conda? Are you in a conda environment? If yes, you can try this command:

conda install -c fastai opencv-python-headless

If that works you will have to install Cell-ACDC manually by installing it without dependencies and installing them one by one. To install Cell-ACDC without dependencies run this command:

pip install --no-deps cellacdc

Then you install the dependencies. These are the required packages that you can install from pip with pip install package-name:

numpy
natsort
h5py
pyqtgraph>=0.13.7
scikit-image>=0.18
tqdm
seaborn
scikit-learn
psutil
boto3
requests
setuptools-scm

Let me know if that works, thanks!

jacobmhkim commented 1 week ago

It seemed to have solved that problem, but I ran into another one. When I try to run acdc, it wants to install QtPy, but I run across an error when it tries to install it:

Cell-ACDC needs to install a GUI library (default library isPyQt6`).

You can install it now or you can close (press "n") and install a compatible GUI library with one of the following commands:

* pip install PyQt6==6.6.0 PyQt6-Qt6==6.6.0
* pip install PyQt5 (or `conda install pyqt`)
* pip install PySide2
* pip install PySide6

Note: if PyQt6 installation fails, you could try installing any of the other libraries.

Do you want to install it now ([y]/n)? y Requirement already satisfied: PyQt6==6.6.0 in /opt/anaconda3/envs/acdc/lib/python3.10/site-packages (6.6.0) Requirement already satisfied: PyQt6-Qt6==6.6.0 in /opt/anaconda3/envs/acdc/lib/python3.10/site-packages (6.6.0) Requirement already satisfied: PyQt6-sip<14,>=13.6 in /opt/anaconda3/envs/acdc/lib/python3.10/site-packages (from PyQt6==6.6.0) (13.6.0) Traceback (most recent call last): File "/opt/anaconda3/envs/acdc/bin/acdc", line 8, in sys.exit(run()) File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cellacdc/main.py", line 49, in run run_gui() File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cellacdc/main.py", line 61, in run_gui _setup_gui_libraries() File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cellacdc/_run.py", line 242, in _setup_gui_libraries import pyqtgraph File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/pyqtgraph/init.py", line 18, in from .colors import palette File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/pyqtgraph/colors/palette.py", line 1, in from ..Qt import QtGui File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/pyqtgraph/Qt/init.py", line 184, in import PyQt6.QtCore ImportError: dlopen(/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/PyQt6/QtCore.abi3.so, 2): Symbol not found: _objc_opt_class Referenced from: /opt/anaconda3/envs/acdc/lib/python3.10/site-packages/PyQt6/Qt6/lib/QtCore.framework/Versions/A/QtCore (which was built for Mac OS X 11.0) Expected in: /usr/lib/libobjc.A.dylib in /opt/anaconda3/envs/acdc/lib/python3.10/site-packages/PyQt6/Qt6/lib/QtCore.framework/Versions/A/QtCore`

ElpadoCan commented 1 week ago

Oh ok, PyQt6 also doesn't seem to be supported on macos 10. I would try pyqt from conda with conda install -c conda-forge pyqt.

You have to uninstall PyQt6 first with pip uninstall PyQt6.

Also, it might be easier to start from scratch.

First check the location of the acdc environment folder with the command conda env list

Then to remove the environment deactivate it and run the command conda env remove -n acdc and check that the acdc folder is gone. If not delete it manually.

You can then restart from scratch and remember conda install -c conda-forge pyqt before running acdc.

Let me know if it works thanks!

ElpadoCan commented 1 week ago

PS: I said "Hi Jordan", but I meant "Hi Jacob", my apologies 😄

jacobmhkim commented 1 week ago

No worries.

We tried re-creating the environment, and got past the issue. But now, we get another error right before acdc loads. We get a flash of the logo before getting this error message:

(acdc) DN0a230841:~ skotheimlab$ acdc Traceback (most recent call last): File "/opt/anaconda3/envs/acdc/bin/acdc", line 8, in <module> sys.exit(run()) File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cellacdc/__main__.py", line 49, in run run_gui() File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cellacdc/__main__.py", line 99, in run_gui app, splashScreen = _run._setup_app(splashscreen=True) File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cellacdc/_run.py", line 361, in _setup_app from . import load File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cellacdc/load.py", line 6, in <module> import cv2 File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cv2/__init__.py", line 181, in <module> bootstrap() File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cv2/__init__.py", line 153, in bootstrap native_module = importlib.import_module("cv2") File "/opt/anaconda3/envs/acdc/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ImportError: dlopen(/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cv2/cv2.abi3.so, 2): Library not loaded: @loader_path/.dylibs/libavcodec.60.31.102.dylib Referenced from: /opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cv2/cv2.abi3.so Reason: no suitable image found. Did find: /opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cv2/.dylibs/libavcodec.60.31.102.dylib: cannot load 'libavcodec.60.31.102.dylib' (load command 0x80000034 is unknown) /opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cv2/.dylibs/libavcodec.60.31.102.dylib: cannot load 'libavcodec.60.31.102.dylib' (load command 0x80000034 is unknown)

ElpadoCan commented 1 week ago

Ok interesting, stupid opencv.

I would try an older version then, maybe something less than 4.9 or even older.

To do so run conda install -c fastai "opencv-python-headless<4.9".

Here you can find the list of all the versions ever released https://anaconda.org/fastai/opencv-python-headless/files?page=1

Let me know if something works thanks!

ElpadoCan commented 1 week ago

You could also try to uninstall opencv-python-headless (with the command conda remove opencv-python-headless and install the non headless version (also try older ones) with the command conda install -c conda-forge opencv

jacobmhkim commented 1 week ago

using the non headless version worked. Thanks!

jacobmhkim commented 1 week ago

Sorry, we got a new error when trying to run the segmentation module, when installing tensorflow. we get this message:

` File "/private/var/folders/n0/y06cp9mx3s337p18h34s6lxw0000gp/T/pip-install-exvx5q3o/grpcio_5685efc0990c4aedbf37be26d17800df/src/python/grpcio/support.py", line 76, in _expect_compile raise commands.CommandError( commands.CommandError: Diagnostics found a compilation environment issue:

  Could not find <Python.h>. This could mean the following:
    * You're on Ubuntu and haven't run `apt-get install python3-dev`.
    * You're on RHEL/Fedora and haven't run `yum install python3-devel` or
      `dnf install python3-devel` (make sure you also have redhat-rpm-config
      installed)
    * You're on Mac OS X and the usual Python framework was somehow corrupted
      (check your environment variables or try re-installing?)
    * You're on Windows and your Python installation was somehow corrupted
      (check your environment variables or try re-installing?)

  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for grpcio Running setup.py clean for grpcio Failed to build grpcio ERROR: Could not build wheels for grpcio, which is required to install pyproject.toml-based projects


File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cellacdc/myutils.py", line 2512 - 14:13:55: Traceback (most recent call last): File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cellacdc/myutils.py", line 2480, in check_install_package import_module(import_pkg_name) File "/opt/anaconda3/envs/acdc/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1004, in _find_and_load_unlocked ModuleNotFoundError: No module named 'tensorflow'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cellacdc/myutils.py", line 2504, in check_install_package _install_tensorflow() File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cellacdc/myutils.py", line 2743, in _install_tensorflow subprocess.check_call(args, shell=shell) File "/opt/anaconda3/envs/acdc/lib/python3.10/subprocess.py", line 369, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['/opt/anaconda3/envs/acdc/bin/Cell-ACDC', '-m', 'pip', 'install', '-U', 'tensorflow']' returned non-zero exit status 1.

`

ElpadoCan commented 1 week ago

Hi Jacob,

I would try to install tensorflow from conda with conda install -c conda-forge tensorflow.

If it works you will need to install yeaz without dependencies because otherwise it would try to install tensorflow too (because yeaz is only with pip and pip cannot see what was installed with conda).

To do that run pip install --no-deps yeaz. It might be that one or two packages are still missing from yeaz dependencies but I'm not sure. If yes, install the missing package too.

Let me know if it works thanks

jacobmhkim commented 1 week ago

We get another error when we do that. it looks like we don't have tensorflow.keras? I looked it up and it looks like we need tensorflow ver 1.14?

`Downloading YeaZ (if needed)... Downloading YeaZ model(s) to "/Users/skotheimlab/acdc-appdata/acdc-YeaZ" Importing YeaZ... 2024-07-12 10:21:24.148217: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: SSE4.1 SSE4.2 AVX AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. Traceback (most recent call last): File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cellacdc/myutils.py", line 2894, in import_segment_module acdcSegment = import_module(f'cellacdc.models.{model_name}.acdcSegment') File "/opt/anaconda3/envs/acdc/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cellacdc/models/YeaZ/acdcSegment.py", line 10, in from .unet import model File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cellacdc/models/YeaZ/unet/model.py", line 12, in from tensorflow.keras.models import Model ModuleNotFoundError: No module named 'tensorflow.keras'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cellacdc/_main.py", line 1597, in launchSegm self.segmWin.main() File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cellacdc/segm.py", line 518, in main acdcSegment = myutils.import_segment_module(model_name) File "/opt/anaconda3/envs/acdc/lib/python3.10/site-packages/cellacdc/myutils.py", line 2899, in import_segment_module model_path = cp[model_name]['path'] File "/opt/anaconda3/envs/acdc/lib/python3.10/configparser.py", line 965, in getitem raise KeyError(key) KeyError: 'YeaZ'`

ElpadoCan commented 1 week ago

Keras should have been installed by tensorflow.

Can you check if you can import tensorflow? In the terminal, with the acdc env activated, type the command python to open python in the terminal then run import tensorflow and then tensorflow.__version__.

Technically YeaZ wants tensorflow <2.0 but we have been using it with tensorflow 2.x for years now and it works I would not worry about that.

One possible explanation is that keras does not have the same version as tensorflow as you can read here https://stackoverflow.com/questions/73796400/error-no-module-named-tensorflow-keras

However, it is much faster to remove the env and try from scratch.

Now that I think about it, it sounds like you want to use yeaz v1 and not v2 right? Because with yeaz v2 they abandoned tensorflow and they use pytorch instead. Do you have a reason for using v1 (like having your custom model)? Because v2 is the same or better than v1 and it might be easier to install pytorch instead of tensorflow.

Let me know thanks!

jacobmhkim commented 1 week ago

I'm using v1 because it seems to work better than v2. We can try v2 though.

we have tensorflow ver 2.16.1

ill try installing keras 2.1

ElpadoCan commented 1 week ago

If YeaZ v1 works better then stick to it absolutely.

Also try older versions of tensorflow, the 2.16 is from 10 days ago and I don't exclude they did not test it on older macos versions. Tensorflow <2.8 should also work. Let me know how it goes, thanks

jacobmhkim commented 1 week ago

2.1 didnt work, but it said tensorflow needs keras 3.0.0, so I tried that, and it seems to work. Thanks!

ElpadoCan commented 1 week ago

Great! Note that 2.1 is different from 2.16 because the 16 is actually 15 versions newer than 1.

Anyway I'm happy it works! Kind of cumbersome but developers are abandoning support to older versions of macos unfortunately.