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' #2637

Closed
Dmitri-Sintsov opened this issue Dec 8, 2022 · 1 comment
Closed

ModuleNotFoundError: No module named 'py' #2637

Dmitri-Sintsov opened this issue Dec 8, 2022 · 1 comment

Comments

@Dmitri-Sintsov
Copy link

Issue

github actions fail with updated to stable tox 4.x

With previous stable version of tox (https://pypi.org/project/tox/3.27.1/) the github actions were running just fine:

https://github.com/Dmitri-Sintsov/djk-sample/actions/runs/3469672017/jobs/5797158793

Now when stable tox 4.x is out and is picked by pip, the actions produce the following error:

https://github.com/Dmitri-Sintsov/djk-sample/actions/runs/3647429807/jobs/6159652294#step:5:74

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/runner/.local/lib/python3.10/site-packages/tox/__main__.py", line 6, in <module>
    run()
  File "/home/runner/.local/lib/python3.10/site-packages/tox/run.py", line 19, in run
    result = main(sys.argv[1:] if args is None else args)
  File "/home/runner/.local/lib/python3.10/site-packages/tox/run.py", line [38](https://github.com/Dmitri-Sintsov/djk-sample/actions/runs/3469672017/jobs/5797158793#step:5:39), in main
    state = setup_state(args)
  File "/home/runner/.local/lib/python3.10/site-packages/tox/run.py", line 53, in setup_state
    options = get_options(*args)
  File "/home/runner/.local/lib/python3.10/site-packages/tox/config/cli/parse.py", line 38, in get_options
    guess_verbosity, log_handler, source = _get_base(args)
  File "/home/runner/.local/lib/python3.10/site-packages/tox/config/cli/parse.py", line 61, in _get_base
    MANAGER.load_plugins(source.path)
  File "/home/runner/.local/lib/python3.10/site-packages/tox/plugin/manager.py", line 83, in load_plugins
    self._register_plugins(inline)
  File "/home/runner/.local/lib/python3.10/site-packages/tox/plugin/manager.py", line 37, in _register_plugins
    self.manager.load_setuptools_entrypoints(NAME)
  File "/home/runner/.local/lib/python3.10/site-packages/pluggy/_manager.py", line 287, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 2[41](https://github.com/Dmitri-Sintsov/djk-sample/actions/runs/3469672017/jobs/5797158793#step:5:42), in _call_with_frames_removed
  File "/home/runner/.local/lib/python3.10/site-packages/tox_pyenv.py", line [47](https://github.com/Dmitri-Sintsov/djk-sample/actions/runs/3469672017/jobs/5797158793#step:5:48), in <module>
    import py
ModuleNotFoundError: No module named 'py'
Error: Process completed with exit code 1.

Environment

Provide at least:

Environment used to run the tests
Kernel version
Linux fv-az251-82 5.15.0-1024-azure #30-Ubuntu SMP Wed Nov 16 [23](https://github.com/Dmitri-Sintsov/djk-sample/actions/runs/3469672017/jobs/5797158793#step:5:24):37:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
System version
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.1 LTS
Release:	22.04
Codename:	jammy
Python version
Python 3.10.8
Chrome version
Google Chrome 108.0.5359.94 
Chrome driver version
ChromeDriver 108.0.5[35](https://github.com/Dmitri-Sintsov/djk-sample/actions/runs/3469672017/jobs/5797158793#step:5:36)9.71 (1e0e3868ee06e91ad6[36](https://github.com/Dmitri-Sintsov/djk-sample/actions/runs/3469672017/jobs/5797158793#step:5:37)a874420e3ca3ae3756ac-refs/branch-heads/5359@{#1016})

Output of running tox

I cannot re-run arbitrary tox commands from github action console, however using local environment with the same Ubuntu 22.04 produces the following error:

user@h67:~/work/djk-sample310/djk-sample$ python3 -m tox -r -e py3.10-django-4.1-bs3
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/user/work/djk-sample310/lib/python3.10/site-packages/tox/__main__.py", line 6, in <module>
    run()
  File "/home/user/work/djk-sample310/lib/python3.10/site-packages/tox/run.py", line 19, in run
    result = main(sys.argv[1:] if args is None else args)
  File "/home/user/work/djk-sample310/lib/python3.10/site-packages/tox/run.py", line 38, in main
    state = setup_state(args)
  File "/home/user/work/djk-sample310/lib/python3.10/site-packages/tox/run.py", line 53, in setup_state
    options = get_options(*args)
  File "/home/user/work/djk-sample310/lib/python3.10/site-packages/tox/config/cli/parse.py", line 38, in get_options
    guess_verbosity, log_handler, source = _get_base(args)
  File "/home/user/work/djk-sample310/lib/python3.10/site-packages/tox/config/cli/parse.py", line 61, in _get_base
    MANAGER.load_plugins(source.path)
  File "/home/user/work/djk-sample310/lib/python3.10/site-packages/tox/plugin/manager.py", line 83, in load_plugins
    self._register_plugins(inline)
  File "/home/user/work/djk-sample310/lib/python3.10/site-packages/tox/plugin/manager.py", line 37, in _register_plugins
    self.manager.load_setuptools_entrypoints(NAME)
  File "/home/user/work/djk-sample310/lib/python3.10/site-packages/pluggy/_manager.py", line 287, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/user/work/djk-sample310/lib/python3.10/site-packages/tox_pyenv.py", line 48, in <module>
    from tox import hookimpl as tox_hookimpl
ImportError: cannot import name 'hookimpl' from 'tox' (/home/user/work/djk-sample310/lib/python3.10/site-packages/tox/__init__.py)

Provide the output of tox -rvv:

user@h67:~/work/djk-sample310/djk-sample$ tox -rvv
Traceback (most recent call last):
  File "/home/user/work/djk-sample310/bin/tox", line 8, in <module>
    sys.exit(run())
  File "/home/user/work/djk-sample310/lib/python3.10/site-packages/tox/run.py", line 19, in run
    result = main(sys.argv[1:] if args is None else args)
  File "/home/user/work/djk-sample310/lib/python3.10/site-packages/tox/run.py", line 38, in main
    state = setup_state(args)
  File "/home/user/work/djk-sample310/lib/python3.10/site-packages/tox/run.py", line 53, in setup_state
    options = get_options(*args)
  File "/home/user/work/djk-sample310/lib/python3.10/site-packages/tox/config/cli/parse.py", line 38, in get_options
    guess_verbosity, log_handler, source = _get_base(args)
  File "/home/user/work/djk-sample310/lib/python3.10/site-packages/tox/config/cli/parse.py", line 61, in _get_base
    MANAGER.load_plugins(source.path)
  File "/home/user/work/djk-sample310/lib/python3.10/site-packages/tox/plugin/manager.py", line 83, in load_plugins
    self._register_plugins(inline)
  File "/home/user/work/djk-sample310/lib/python3.10/site-packages/tox/plugin/manager.py", line 37, in _register_plugins
    self.manager.load_setuptools_entrypoints(NAME)
  File "/home/user/work/djk-sample310/lib/python3.10/site-packages/pluggy/_manager.py", line 287, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/user/work/djk-sample310/lib/python3.10/site-packages/tox_pyenv.py", line 48, in <module>
    from tox import hookimpl as tox_hookimpl
ImportError: cannot import name 'hookimpl' from 'tox' (/home/user/work/djk-sample310/lib/python3.10/site-packages/tox/__init__.py)
user@h67:~/work/djk-sample310/djk-sample$ 

Minimal example

One may re-run project jobs manually, however tox has to be updated or perhaps something has to be fixed in tox.ini and / or github actions settings.

Reverting locally to tox 3.x works fine in the same local environment:

user@h67:~/work/djk-sample310/djk-sample$ pip3 install tox==3.27.1
Collecting tox==3.27.1
  Using cached tox-3.27.1-py2.py3-none-any.whl (86 kB)
Requirement already satisfied: tomli>=2.0.1 in /home/user/work/djk-sample310/lib/python3.10/site-packages (from tox==3.27.1) (2.0.1)
Requirement already satisfied: packaging>=14 in /home/user/work/djk-sample310/lib/python3.10/site-packages (from tox==3.27.1) (22.0)
Requirement already satisfied: filelock>=3.0.0 in /home/user/work/djk-sample310/lib/python3.10/site-packages (from tox==3.27.1) (3.8.2)
Requirement already satisfied: pluggy>=0.12.0 in /home/user/work/djk-sample310/lib/python3.10/site-packages (from tox==3.27.1) (1.0.0)
Requirement already satisfied: virtualenv!=20.0.0,!=20.0.1,!=20.0.2,!=20.0.3,!=20.0.4,!=20.0.5,!=20.0.6,!=20.0.7,>=16.0.0 in /home/user/work/djk-sample310/lib/python3.10/site-packages (from tox==3.27.1) (20.17.1)
Requirement already satisfied: six>=1.14.0 in /home/user/work/djk-sample310/lib/python3.10/site-packages (from tox==3.27.1) (1.16.0)
Requirement already satisfied: py>=1.4.17 in /home/user/work/djk-sample310/lib/python3.10/site-packages (from tox==3.27.1) (1.11.0)
Requirement already satisfied: platformdirs<3,>=2.4 in /home/user/work/djk-sample310/lib/python3.10/site-packages (from virtualenv!=20.0.0,!=20.0.1,!=20.0.2,!=20.0.3,!=20.0.4,!=20.0.5,!=20.0.6,!=20.0.7,>=16.0.0->tox==3.27.1) (2.6.0)
Requirement already satisfied: distlib<1,>=0.3.6 in /home/user/work/djk-sample310/lib/python3.10/site-packages (from virtualenv!=20.0.0,!=20.0.1,!=20.0.2,!=20.0.3,!=20.0.4,!=20.0.5,!=20.0.6,!=20.0.7,>=16.0.0->tox==3.27.1) (0.3.6)
Installing collected packages: tox
  Attempting uninstall: tox
    Found existing installation: tox 4.0.2
    Uninstalling tox-4.0.2:
      Successfully uninstalled tox-4.0.2
Successfully installed tox-3.27.1
user@h67:~/work/djk-sample310/djk-sample$ 
user@h67:~/work/djk-sample310/djk-sample$ python3 -m tox -r -e py3.10-django-4.1-bs3
py3.10-django-4.1-bs3 create: /home/user/work/djk-sample310/djk-sample/.tox/py3.10-django-4.1-bs3
py3.10-django-4.1-bs3 installdeps: git+https://github.com/Dmitri-Sintsov/djk-bootstrap3.git, Django>=4.1,<4.2, django-allauth, -r/home/user/work/djk-sample310/djk-sample/requirements/dev.txt
@jugmac00
Copy link
Member

jugmac00 commented Dec 8, 2022

Thanks for the detailed report.

This is not an issue in tox, but in tox-pyenv.

It has been already reported at tox-dev/tox-pyenv#21

To get unblocked, you could pin tox < 4 until somebody updates tox-pyenv.

Please know that this plugin is not maintained by the tox core maintainers, and we have no capacity to help here.

@jugmac00 jugmac00 closed this as completed Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants