atarashansky / SAMap

SAMap: Mapping single-cell RNA sequencing datasets from evolutionarily distant organisms.
MIT License
66 stars 19 forks source link

Installation issue in numpy import #91

Closed Hrovatin closed 1 year ago

Hrovatin commented 2 years ago

I tried to install SAMap, but it fails due to numpy import. When I open python in the conda env and make the same import it works, so I was wondering if this may be something specific to SAMap intall rather than whole env. I also tried multiple things suggested to fix the numpy error (checking versions, re-creating env, ...), but it did not work.

Install SAMap

(SAMap) -bash-4.2$ pip install .
Processing /home/icb/karin.hrovatin/miniconda3/envs/SAMap/lib/python3.7/site-packages/SAMap
  Preparing metadata (setup.py) ... done
Collecting sam-algorithm
  Using cached sam-algorithm-1.0.1.tar.gz (35 kB)
  Preparing metadata (setup.py) ... done
Collecting scanpy
  Using cached scanpy-1.9.1-py3-none-any.whl (2.0 MB)
Collecting hnswlib
  Using cached hnswlib-0.6.2.tar.gz (31 kB)
  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
  ╰─> [51 lines of output]
      Traceback (most recent call last):
        File "/tmp/pip-build-env-ulqvt217/overlay/lib/python3.7/site-packages/numpy/core/__init__.py", line 22, in <module>
          from . import multiarray
        File "/tmp/pip-build-env-ulqvt217/overlay/lib/python3.7/site-packages/numpy/core/multiarray.py", line 12, in <module>
          from . import overrides
        File "/tmp/pip-build-env-ulqvt217/overlay/lib/python3.7/site-packages/numpy/core/overrides.py", line 7, in <module>
          from numpy.core._multiarray_umath import (
      ImportError: /tmp/pip-build-env-ulqvt217/overlay/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-x86_64-linux-gnu.so: failed to map segment from shared object: Operation not permitted

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
        File "/home/icb/karin.hrovatin/miniconda3/envs/SAMap/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/home/icb/karin.hrovatin/miniconda3/envs/SAMap/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/icb/karin.hrovatin/miniconda3/envs/SAMap/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/tmp/pip-build-env-ulqvt217/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 338, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/tmp/pip-build-env-ulqvt217/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 320, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-ulqvt217/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 335, in run_setup
          exec(code, locals())
        File "<string>", line 5, in <module>
        File "/tmp/pip-build-env-ulqvt217/overlay/lib/python3.7/site-packages/numpy/__init__.py", line 150, in <module>
          from . import core
        File "/tmp/pip-build-env-ulqvt217/overlay/lib/python3.7/site-packages/numpy/core/__init__.py", line 48, in <module>
          raise ImportError(msg)
      ImportError:

      IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

      Importing the numpy C-extensions failed. This error can happen for
      many reasons, often due to issues with your setup or how NumPy was
      installed.

      We have compiled some common reasons and troubleshooting tips at:

          https://numpy.org/devdocs/user/troubleshooting-importerror.html

      Please note and check the following:

        * The Python version is: Python3.7 from "/home/icb/karin.hrovatin/miniconda3/envs/SAMap/bin/python"
        * The NumPy version is: "1.21.6"

      and make sure that they are the versions you expect.
      Please carefully study the documentation linked above for further help.

      Original error was: /tmp/pip-build-env-ulqvt217/overlay/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-x86_64-linux-gnu.so: failed to map segment from shared object: Operation not permitted

      [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.

Import numpy (and use the lines that erro out in setup) in python in the same env

(SAMap) -bash-4.2$ python
Python 3.7.13 (default, Oct 18 2022, 18:57:03) 
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> from numpy.core._multiarray_umath import *
>>> from numpy.core import multiarray
>>>  
atarashansky commented 2 years ago

Can you try pip install hnswlib by itself to see if you can reproduce the error? If you still get an error, please try uninstall numpy first and then rerunning pip install hnswlib.

Hrovatin commented 1 year ago

I resolved the issue with installing hnswlib by changing the tmpdir for pip install since we apparently did not have exec permissions on the /tmp dir which was used by default. TMPDIR=/localscratch/$USER/tmpconda pip install hnswlib