Skip to content

Fix ModuleNotFoundError: No module named 'pkg_resources' error - #2889

Open
votdev wants to merge 1 commit into
harvester:mainfrom
votdev:fix-robot-tests
Open

votdev wants to merge 1 commit into
harvester:mainfrom
votdev:fix-robot-tests

Conversation

@votdev

@votdev votdev commented Sep 15, 2026

Copy link
Copy Markdown
Member

... which is caused due pypa/setuptools#5007.

Running tests...
==============================================================================
Test Vm :: VM Test Cases: basic lifecycle, create-stopped, and volume hot-p...
==============================================================================
Test VM Basic Lifecycle :: Test basic VM creation, start, stop, de... | FAIL |
Parent suite setup failed:
ModuleNotFoundError: No module named 'pkg_resources'
------------------------------------------------------------------------------
Create Stopped VM Stays Stopped :: A VM created with runStrategy=H... | FAIL |
Parent suite setup failed:
ModuleNotFoundError: No module named 'pkg_resources'
------------------------------------------------------------------------------
Start Stopped VM :: Starting the stopped VM brings it to running      | FAIL |
Parent suite setup failed:
ModuleNotFoundError: No module named 'pkg_resources'
------------------------------------------------------------------------------
Hot-Plug Volume Into Running VM :: Hot-plug an existing volume int... | FAIL |
Parent suite setup failed:
ModuleNotFoundError: No module named 'pkg_resources'
------------------------------------------------------------------------------
Hot-Unplug Volume From Running VM :: Hot-unplug the disk; it must ... | FAIL |
Parent suite setup failed:
ModuleNotFoundError: No module named 'pkg_resources'
------------------------------------------------------------------------------
Test Vm :: VM Test Cases: basic lifecycle, create-stopped, and vol... | FAIL |
Suite setup failed:
ModuleNotFoundError: No module named 'pkg_resources'

5 tests, 0 passed, 5 failed

Additional fixes:

  • Fix crash when using a nightly build cluster which returns a git hash instead a semver.
InvalidVersion: Invalid version: 'c6d323ec'

@m-ildefons m-ildefons left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, the dependencies of the robot tests are managed through requirements.in/requirements.txt in the harvester_robot_tests directory, not the top-level requirements files.

Aside from that, I'd prefer to pin this with the other dependencies rather than have it as separate install command documented.

Comment thread harvester_robot_tests/README.md Outdated
> You need to install `setuptools` version 81 because `pkg_resources` has been removed in version >= 82. See https://github.com/pypa/setuptools/pull/5007.

```bash
pip install setuptools==81.0.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just add this to test-requirements.in?

The fact that this isn't pinned there is even warned about in test-requirements.txt:

# WARNING: The following packages were not pinned, but pip requires them to be
# pinned when the requirements file includes hashes and the requirement is not
# satisfied by a package already installed. Consider using the --allow-unsafe flag.
# setuptools

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, if this package is missing in a fresh robot env., we should add it in requirement.in and regenerate requirement.txt too.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pip-tools is considering setuptools as unsafe. But we can force it with --allow-unsafe. I think that’s fine in our case, as we specifically need this version of setuptools.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With my first attempt at the PR, I didn’t want to do anything that went against the ‘normal’ behaviour of pip-tools; but I think forcing it is ultimately the better and simpler solution.

... which is caused due pypa/setuptools#5007.

- Add `setuptools==81.0.0` to forceible install the required package.
- Fix crash when using a nightly build cluster which returns a git hash instead a semver.
```
InvalidVersion: Invalid version: 'c6d323ec'
```

Signed-off-by: Volker Theile <vtheile@suse.com>
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

Successfully merging this pull request may close these issues.

3 participants