Teichlab / cellphonedb

MIT License
339 stars 105 forks source link

ModuleNotFoundError: No module named 'sklearn.cluster.k_means_' #247

Closed dfermin closed 3 years ago

dfermin commented 3 years ago

Hi

I just installed the latest-n-greatest release version of cellphonedb under Anaconda python 3.7.9

Installation with pip went without a hitch. However when I run the demo command: cellphonedb method analysis test_meta.txt test_counts.txt

I get an error:

Traceback (most recent call last):
  File "/Users/dfermin/anaconda3/envs/cellphonedb/bin/cellphonedb", line 5, in <module>
    from cellphonedb.cellphonedb_cli import cli
  File "/Users/dfermin/anaconda3/envs/cellphonedb/lib/python3.7/site-packages/cellphonedb/cellphonedb_cli.py", line 6, in <module>
    from cellphonedb.src.api_endpoints.terminal_api.database_terminal_api_endpoints import database_terminal_commands
  File "/Users/dfermin/anaconda3/envs/cellphonedb/lib/python3.7/site-packages/cellphonedb/src/api_endpoints/terminal_api/database_terminal_api_endpoints/database_terminal_commands.py", line 8, in <module>
    from cellphonedb.src.api_endpoints.terminal_api.tools_terminal_api_endpoints.tools_terminal_commands import \
  File "/Users/dfermin/anaconda3/envs/cellphonedb/lib/python3.7/site-packages/cellphonedb/src/api_endpoints/terminal_api/tools_terminal_api_endpoints/tools_terminal_commands.py", line 9, in <module>
    from cellphonedb.src.app.cellphonedb_app import output_dir, data_dir
  File "/Users/dfermin/anaconda3/envs/cellphonedb/lib/python3.7/site-packages/cellphonedb/src/app/cellphonedb_app.py", line 3, in <module>
    from cellphonedb.src.app.flask.flask_cellphonedb import CellphonedbFlask
  File "/Users/dfermin/anaconda3/envs/cellphonedb/lib/python3.7/site-packages/cellphonedb/src/app/flask/flask_cellphonedb.py", line 1, in <module>
    from cellphonedb.src.core.CellphonedbSqlalchemy import CellphonedbSqlalchemy
  File "/Users/dfermin/anaconda3/envs/cellphonedb/lib/python3.7/site-packages/cellphonedb/src/core/CellphonedbSqlalchemy.py", line 5, in <module>
    from cellphonedb.src.core.Cellphonedb import Cellphonedb
  File "/Users/dfermin/anaconda3/envs/cellphonedb/lib/python3.7/site-packages/cellphonedb/src/core/Cellphonedb.py", line 5, in <module>
    from cellphonedb.src.core.methods.method_launcher import MethodLauncher
  File "/Users/dfermin/anaconda3/envs/cellphonedb/lib/python3.7/site-packages/cellphonedb/src/core/methods/method_launcher.py", line 8, in <module>
    from cellphonedb.src.core.utils.subsampler import Subsampler
  File "/Users/dfermin/anaconda3/envs/cellphonedb/lib/python3.7/site-packages/cellphonedb/src/core/utils/subsampler.py", line 4, in <module>
    from geosketch import gs
  File "/Users/dfermin/anaconda3/envs/cellphonedb/lib/python3.7/site-packages/geosketch/__init__.py", line 1, in <module>
    from .sketch import *
  File "/Users/dfermin/anaconda3/envs/cellphonedb/lib/python3.7/site-packages/geosketch/sketch.py", line 7, in <module>
    from .kmeanspp import kmeanspp
  File "/Users/dfermin/anaconda3/envs/cellphonedb/lib/python3.7/site-packages/geosketch/kmeanspp.py", line 1, in <module>
    from sklearn.cluster.k_means_ import *
ModuleNotFoundError: No module named 'sklearn.cluster.k_means_'

This seems strange to me because scikit was installed:

python -c "import sklearn; sklearn.show_versions()"

System:
    python: 3.7.9 | packaged by conda-forge | (default, Dec  9 2020, 20:58:55)  [Clang 11.0.0 ]
executable: /Users/dfermin/anaconda3/envs/cellphonedb/bin/python
   machine: Darwin-19.6.0-x86_64-i386-64bit

Python dependencies:
          pip: 20.3.3
   setuptools: 49.6.0.post20201009
      sklearn: 0.24.0rc1
        numpy: 1.19.4
        scipy: 1.5.4
       Cython: 0.29.21
       pandas: 0.23.4
   matplotlib: None
       joblib: 1.0.0
threadpoolctl: 2.1.0

Any suggestions on how to fix it?

Thanks,

Jiam1ng commented 3 years ago

I have just met the same issue, it seems to have something to with the module version and naming. I reinstall the sklearn with pip install scikit-learn==0.20.4, and that works for me.

YinCY123 commented 3 years ago

I have just met the same issue, it seems to have something to with the module version and naming. I reinstall the sklearn with pip install scikit-learn==0.20.4, and that works for me.

that works for me!!

prete commented 3 years ago

CellPhoneDB requires scikit-learn>=0.20.4,<=0.22.0 for its geosketch==0.3 dependency and if you've got a more recent version you need to downgrade using pip install -U scikit-learn==0.22