theislab / cpa

The Compositional Perturbation Autoencoder (CPA) is a deep generative framework to learn effects of perturbations at the single-cell level. CPA performs OOD predictions of unseen combinations of drugs, learns interpretable embeddings, estimates dose-response curves, and provides uncertainty estimates.
BSD 3-Clause "New" or "Revised" License
83 stars 17 forks source link

Issue Installing CPA #50

Closed ahummels closed 4 months ago

ahummels commented 5 months ago

I am attempting to install CPA in a new conda environment with only base python packages installed. I created my environment with this command

conda create -n cpa-test python

and after activating the environment then ran the pip install recommended

pip install git+https://github.com/theislab/cpa

but ran into the following error.

Collecting numpy<1.24,>=1.22.4 (from cpa-tools==0.8.7)
  Using cached numpy-1.23.5.tar.gz (10.7 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [33 lines of output]
      Traceback (most recent call last):
        File "/net/dali/home/camacho/arh152/.conda/envs/cpa-test/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/net/dali/home/camacho/arh152/.conda/envs/cpa-test/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/net/dali/home/camacho/arh152/.conda/envs/cpa-test/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 112, in get_requires_for_build_wheel
          backend = _build_backend()
                    ^^^^^^^^^^^^^^^^
        File "/net/dali/home/camacho/arh152/.conda/envs/cpa-test/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 77, in _build_backend
          obj = import_module(mod_path)
                ^^^^^^^^^^^^^^^^^^^^^^^
        File "/net/dali/home/camacho/arh152/.conda/envs/cpa-test/lib/python3.12/importlib/__init__.py", line 90, in import_module
          return _bootstrap._gcd_import(name[level:], package, level)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
        File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
        File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
        File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
        File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
        File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
        File "<frozen importlib._bootstrap_external>", line 995, in exec_module
        File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
        File "/tmp/pip-build-env-6f3qe97d/overlay/lib/python3.12/site-packages/setuptools/__init__.py", line 16, in <module>
          import setuptools.version
        File "/tmp/pip-build-env-6f3qe97d/overlay/lib/python3.12/site-packages/setuptools/version.py", line 1, in <module>
          import pkg_resources
        File "/tmp/pip-build-env-6f3qe97d/overlay/lib/python3.12/site-packages/pkg_resources/__init__.py", line 2172, in <module>
          register_finder(pkgutil.ImpImporter, find_on_path)
                          ^^^^^^^^^^^^^^^^^^^
      AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

This was done on a SLURM cluster, but I also attempted this on my desktop and ran into the exact same issue at the same spot. I can use cpa on the provided colab notebooks, but can't do much of substance without paying for compute units and would appreciate any help. Here is the list of packages I'm working with

# packages in environment at /net/dali/home/camacho/arh152/.conda/envs/cpa-test:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main
_openmp_mutex             5.1                       1_gnu
bzip2                     1.0.8                h5eee18b_6
ca-certificates           2024.3.11            h06a4308_0
expat                     2.6.2                h6a678d5_0
ld_impl_linux-64          2.38                 h1181459_1
libffi                    3.4.4                h6a678d5_1
libgcc-ng                 11.2.0               h1234567_1
libgomp                   11.2.0               h1234567_1
libstdcxx-ng              11.2.0               h1234567_1
libuuid                   1.41.5               h5eee18b_0
ncurses                   6.4                  h6a678d5_0
openssl                   3.0.13               h7f8727e_1
pip                       23.3.1          py312h06a4308_0
python                    3.12.3               h996f2a0_0
readline                  8.2                  h5eee18b_0
setuptools                68.2.2          py312h06a4308_0
sqlite                    3.45.3               h5eee18b_0
tk                        8.6.12               h1ccaba5_0
tzdata                    2024a                h04d1e81_0
wheel                     0.43.0          py312h06a4308_0
xz                        5.4.6                h5eee18b_1
zlib                      1.2.13               h5eee18b_1
ArianAmani commented 4 months ago

Hi @ahummels Thanks for your interest in CPA. The problem you are facing is because of the Python version you are using. (Addressed here) By not specifying the python version, you are installing Python 3.12 which is not tested/supported by CPA and several dependency libraries.

Creating the environment with Python 3.9 should fix your problem:

conda create -n cpa python=3.9

Feel free to comment and open this issue if you are still facing this problem with Python 3.9.