Skip to content

ModuleNotFoundError: No module named 'numpy' when py-numcodecs@0.7.3 pytest #22299

@Tom-python0121

Description

@Tom-python0121

Hello,I meet a problem about ModuleNotFoundError: No module named 'numpy' when py-numcodecs@0.7.3 pytest.

Steps to reproduce the issue

localhost:/tmp/root/spack-stage/spack-stage-py-numcodecs-0.7.3-mdm2ofae7zyu6ymyvqmhpiixwjcfjqpa/spack-src #spack load py-numcodecs@0.7.3
localhost:/tmp/root/spack-stage/spack-stage-py-numcodecs-0.7.3-mdm2ofae7zyu6ymyvqmhpiixwjcfjqpa/spack-src #spack load py-pip
localhost:/tmp/root/spack-stage/spack-stage-py-numcodecs-0.7.3-mdm2ofae7zyu6ymyvqmhpiixwjcfjqpa/spack-src # ls
CODE_OF_CONDUCT.md  MANIFEST.in  README.rst   adhoc  build.cmd  cpuinfo.py  fixture    numcodecs           pytest.ini        requirements_dev.txt   requirements_test.txt  setup.py
LICENSE             PKG-INFO     __pycache__  build  c-blosc    docs        notebooks  numcodecs.egg-info  requirements.txt  requirements_rtfd.txt  setup.cfg              tox.ini
localhost:/tmp/root/spack-stage/spack-stage-py-numcodecs-0.7.3-mdm2ofae7zyu6ymyvqmhpiixwjcfjqpa/spack-src #pip install -r requirements.txt
localhost:/tmp/root/spack-stage/spack-stage-py-numcodecs-0.7.3-mdm2ofae7zyu6ymyvqmhpiixwjcfjqpa/spack-src #pip install -r requirements_test.txt
localhost:/tmp/root/spack-stage/spack-stage-py-numcodecs-0.7.3-mdm2ofae7zyu6ymyvqmhpiixwjcfjqpa/spack-src #python setup.py test
localhost:/tmp/root/spack-stage/spack-stage-py-numcodecs-0.7.3-mdm2ofae7zyu6ymyvqmhpiixwjcfjqpa/spack-src #pytest           
……
    from numcodecs.zlib import Zlib
numcodecs/zlib.py:5: in <module>
    from .compat import ndarray_copy, ensure_contiguous_ndarray
numcodecs/compat.py:7: in <module>
    import numpy as np
E   ModuleNotFoundError: No module named 'numpy'
_________________________________________________________________________________ ERROR collecting numcodecs/tests/test_zlib.py _________________________________________________________________________________
ImportError while importing test module '/tmp/root/spack-stage/spack-stage-py-numcodecs-0.7.3-mdm2ofae7zyu6ymyvqmhpiixwjcfjqpa/spack-src/numcodecs/tests/test_zlib.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/home/spack/opt/spack/linux-sles15-aarch64/gcc-7.4.0/python-3.7.7-tmyoucv3qh4ffcqbrqc7wcehar7a2n3w/lib/python3.7/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
numcodecs/__init__.py:27: in <module>
    from numcodecs.zlib import Zlib
numcodecs/zlib.py:5: in <module>
    from .compat import ndarray_copy, ensure_contiguous_ndarray
numcodecs/compat.py:7: in <module>
    import numpy as np
E   ModuleNotFoundError: No module named 'numpy'
_________________________________________________________________________________ ERROR collecting numcodecs/tests/test_zstd.py _________________________________________________________________________________
ImportError while importing test module '/tmp/root/spack-stage/spack-stage-py-numcodecs-0.7.3-mdm2ofae7zyu6ymyvqmhpiixwjcfjqpa/spack-src/numcodecs/tests/test_zstd.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/home/spack/opt/spack/linux-sles15-aarch64/gcc-7.4.0/python-3.7.7-tmyoucv3qh4ffcqbrqc7wcehar7a2n3w/lib/python3.7/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
numcodecs/__init__.py:27: in <module>
    from numcodecs.zlib import Zlib
numcodecs/zlib.py:5: in <module>
    from .compat import ndarray_copy, ensure_contiguous_ndarray
numcodecs/compat.py:7: in <module>
    import numpy as np
E   ModuleNotFoundError: No module named 'numpy'
============================================================================================ short test summary info ============================================================================================
ERROR numcodecs/tests/test_astype.py
ERROR numcodecs/tests/test_base64.py
ERROR numcodecs/tests/test_blosc.py
ERROR numcodecs/tests/test_bz2.py
ERROR numcodecs/tests/test_categorize.py
ERROR numcodecs/tests/test_checksum32.py
ERROR numcodecs/tests/test_compat.py
ERROR numcodecs/tests/test_delta.py
ERROR numcodecs/tests/test_fixedscaleoffset.py
ERROR numcodecs/tests/test_gzip.py
ERROR numcodecs/tests/test_json.py
ERROR numcodecs/tests/test_lz4.py
ERROR numcodecs/tests/test_lzma.py
ERROR numcodecs/tests/test_msgpacks.py
ERROR numcodecs/tests/test_packbits.py
ERROR numcodecs/tests/test_pickles.py
ERROR numcodecs/tests/test_quantize.py
ERROR numcodecs/tests/test_registry.py
ERROR numcodecs/tests/test_vlen_array.py
ERROR numcodecs/tests/test_vlen_bytes.py
ERROR numcodecs/tests/test_vlen_utf8.py
ERROR numcodecs/tests/test_zlib.py
ERROR numcodecs/tests/test_zstd.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 23 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

localhost:/tmp/root/spack-stage/spack-stage-py-numcodecs-0.7.3-mdm2ofae7zyu6ymyvqmhpiixwjcfjqpa/spack-src # spack edit py-numcodecs
# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack import *


class PyNumcodecs(PythonPackage):
    """Numcodecs is a Python package providing buffer compression and
    transformation codecs for use in data storage and communication
    applications.
    """

    homepage = "https://github.com/zarr-developers/numcodecs"
    url      = "https://pypi.io/packages/source/n/numcodecs/numcodecs-0.6.4.tar.gz"

    version('0.7.3', sha256='022b12ad83eb623ec53f154859d49f6ec43b15c36052fa864eaf2d9ee786dd85')
    version('0.6.4', sha256='ef4843d5db4d074e607e9b85156835c10d006afc10e175bda62ff5412fca6e4d')

    variant('msgpack', default=False, description='Codec to encode data as msgpacked bytes.')

    depends_on('py-setuptools@18.0:',       type='build')
    depends_on('py-setuptools-scm@1.5.4:',  type=('build', 'run'))
    depends_on('py-numpy@1.7:',             type=('build', 'run'))
    depends_on('py-msgpack', type=('build', 'run'), when='+msgpack')

I want to know why pytest still reports ModuleNotFoundError: No module named'numpy' when the package package contains the numpy dependency. Whether the path of py-numpy is not found during the spack setting. As a result, the spack load py-numcodecs does not load dependent py-numpy, and I need to load it again. Can you help me analyze it?

Information on your system

localhost:/tmp/root/spack-stage/spack-stage-py-numcodecs-0.7.3-mdm2ofae7zyu6ymyvqmhpiixwjcfjqpa/spack-src # spack debug report

  • Spack: 0.16.0-77-98460b6f47
  • Python: 3.8.6
  • Platform: linux-sles15-aarch64
  • Concretizer: original

Additional information

  • I have run spack debug report and reported the version of Spack/Python/Platform
  • I have searched the issues of this repo and believe this is not a duplicate
  • I have run the failing commands in debug mode and reported the output

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtriageThe issue needs to be prioritized

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions