caokai1073 / uniPort

a unified single-cell data integration framework by optimal transport
MIT License
30 stars 3 forks source link

Bad Installation --> AttributeError: module 'numpy' has no attribute 'warnings'. #7

Closed mortunco closed 1 year ago

mortunco commented 1 year ago

Hello.

I am having problems importing uniport. Basically, I created a fresh conda environment with pip and followed installation procedure. Here is the output.

(uniport-4) $ python
Python 3.10.9 (main, Jan 11 2023, 15:21:40) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import uniport as up
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ec2-user/synlico-efs/tme/st-sc-integration/uniport/code/uniPort/uniport/__init__.py", line 8, in <module>
    from .function import Run, get_prior, label_reweight, load_file, filter_data, batch_scale, TFIDF_LSI
  File "/home/ec2-user/synlico-efs/tme/st-sc-integration/uniport/code/uniPort/uniport/function.py", line 28, in <module>
    np.warnings.filterwarnings('ignore')
  File "/opt/conda/envs/uniport-4/lib/python3.10/site-packages/numpy/__init__.py", line 320, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'warnings'. Did you mean: 'hanning'?

Here is the relavent packages with their version.

numpy                     1.24.4                   pypi_0    pypi
pandas                    2.0.2                    pypi_0    pypi
scanpy                    1.9.3                    pypi_0    pypi

I think this is a numpy version problem. To solve this, I also created a fresh conda env and tried pip install -r requirements in the repo. Same problem. I also tried installing without "=>" and made the versions exact. Pip install failed during the installation.

I would appreciate if could help me with this. We loved the tool, we loved the paper. Would like to implement to our work.

Best regards,

T.

mortunco commented 1 year ago

I try to remove that line np.warnings.filterwarnings('ignore') from uniport/function.py and build it from the source but couldnt figure it out.

Is there a way to pip install uniprot from my own fork?

Code below didnt work.

(uniport-5) $ pip install git+https://github.com/mortunco/uniPort@main
Collecting git+https://github.com/mortunco/uniPort@main
  Cloning https://github.com/mortunco/uniPort (to revision main) to /tmp/pip-req-build-8bruelni
  Running command git clone --filter=blob:none --quiet https://github.com/mortunco/uniPort /tmp/pip-req-build-8bruelni
  Resolved https://github.com/mortunco/uniPort to commit 06f58d8128d1a2fcdb18120c71a098d444e4755d
  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
  ╰─> [15 lines of output]
      Traceback (most recent call last):
        File "/opt/conda/envs/uniport-5/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/opt/conda/envs/uniport-5/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/opt/conda/envs/uniport-5/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-4ddh56s0/overlay/lib/python3.11/site-packages/flit_core/buildapi.py", line 31, in get_requires_for_build_wheel
          module = Module(info.module, Path.cwd())
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-4ddh56s0/overlay/lib/python3.11/site-packages/flit_core/common.py", line 59, in __init__
          raise ValueError("No file/folder found for module {}".format(name))
      ValueError: No file/folder found for module uniPort
      [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.
caokai1073 commented 1 year ago

Hi, thanks for your interest! Could you please downgrade your numpy version, e.g., numpy 1.23.0? I tried this version and it works.

mortunco commented 1 year ago

Hi. Thank you very much for your swift response. Your suggestion worked! I am leaving this here for future in case anyone else has the issue.

$ conda create --name uniport-env
$ conda activate uniport-env
$ pip install uniport numpy==1.23.0
$ python
Python 3.11.4 | packaged by conda-forge | (main, Jun 10 2023, 18:08:17) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import uniport as up
>>>
mortunco commented 1 year ago

quick addition:

If you are trying to follow the MERFISH Impute Genes tutorial. You will need sciVi.

In that case, numpy==1.23.3 solved the dependency conflict.