Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'py' #565

Closed
sr-verde opened this issue Nov 2, 2020 · 2 comments
Closed

ModuleNotFoundError: No module named 'py' #565

sr-verde opened this issue Nov 2, 2020 · 2 comments
Labels

Comments

@sr-verde
Copy link

sr-verde commented Nov 2, 2020

Describe the bug
Unittest fails with ModuleNotFoundError: No module named 'py'

$ python -m unittest
E
======================================================================
ERROR: tests.utils.test_config (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: tests.utils.test_config
Traceback (most recent call last):
  File "/usr/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/home/user/git/some/tests/utils/test_config.py", line 4, in <module>
    from pyfakefs.fake_filesystem_unittest import TestCase as FakeFsTestCase
  File "/home/user/git/some/venv/lib/python3.8/site-packages/pyfakefs/fake_filesystem_unittest.py", line 49, in <module>
    import py
ModuleNotFoundError: No module named 'py'

This error does not happen with PyFakeFS versions less 4.2.

How To Reproduce
Minimal example:

from pyfakefs.fake_filesystem_unittest import TestCase as FakeFsTestCase


class TestConfigReadsProperly(FakeFsTestCase):
    def setUp(self):
        self.setUpPyfakefs()

    def test_mock(self):
        pass

Your enviroment

$ python -c "import platform; print(platform.platform())"
Linux-5.9.2-arch1-1-x86_64-with-glibc2.2.5
$ python -c "import sys; print('Python', sys.version)"
Python 3.8.6 (default, Sep 30 2020, 04:00:38) 
[GCC 10.2.0]
$ python -c "from pyfakefs.fake_filesystem import __version__; print('pyfakefs', __version__)"
pyfakefs 4.2.0
mtreinish added a commit to mtreinish/qiskit-ignis that referenced this issue Nov 2, 2020
The recent pyfakefs 4.2.0 release is raising an import error whenever
it's imported, see pytest-dev/pyfakefs#565 for more details. This commit
pins the pyfakefs version to the last known working version until there
is a new release fixing this issue.
@mrbean-bremen
Copy link
Member

Thanks - I seem to have introduced a dependency to pytest here. Didn't notice this because pytest is always installed as a development dependency. I will try to fix this ASAP, for the time being the workaround is either to pin pyfakefs to the previous version, or add pytest to the dependencies.

mrbean-bremen added a commit to mrbean-bremen/pyfakefs that referenced this issue Nov 2, 2020
mrbean-bremen added a commit to mrbean-bremen/pyfakefs that referenced this issue Nov 2, 2020
@mrbean-bremen
Copy link
Member

mrbean-bremen commented Nov 2, 2020

@sr-verde, @mtreinish - I have published a new patch release (4.2.1) with the fix.

chriseclectic pushed a commit to qiskit-community/qiskit-ignis that referenced this issue Nov 2, 2020
* Pin pyfakefs to avoid broken release

The recent pyfakefs 4.2.0 release is raising an import error whenever
it's imported, see pytest-dev/pyfakefs#565 for more details. This commit
pins the pyfakefs version to the last known working version until there
is a new release fixing this issue.

* Ignore numba namespace in pylint
mtreinish added a commit to mtreinish/qiskit-ignis that referenced this issue Nov 12, 2020
* Pin pyfakefs to avoid broken release

The recent pyfakefs 4.2.0 release is raising an import error whenever
it's imported, see pytest-dev/pyfakefs#565 for more details. This commit
pins the pyfakefs version to the last known working version until there
is a new release fixing this issue.

* Ignore numba namespace in pylint

(cherry picked from commit c572b34)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants