Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip install RandomWords: "No module named 'setuptools.command.test'"

Tags:

python

pip

I'm using pip 24.2 and Python 3.12.4. I want to install this:

$ pip install RandomWords
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
python setup.py egg_info did not run successfully.
exit code: 1
from setuptools.command.test import test as TestCommand
ModuleNotFoundError: No module named 'setuptools.command.test'
 note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Why is this and how can I fix it?

like image 340
Rzeyee Avatar asked Sep 01 '25 10:09

Rzeyee


2 Answers

It seems that their package is broken. This is because in setup.py they are doing

from setuptools.command.test import test as TestCommand

but setuptools.command.test was removed on 28 Jul 2024 (yesterday): https://setuptools.pypa.io/en/stable/history.html#v72-0-0

Here's a similar issue on the official GitHub repo: https://github.com/pypa/setuptools/issues/4519


To solve it locally do one of the following:

  • downgrade your setuptools as @reza.safiyat suggested;
  • use a project manager (like Poetry or Hatch) and pin setuptools = "<72.0.0".

UPDATE

setuptools 72.0.0 has been yanked (https://pypi.org/project/setuptools/72.0.0/#history) and the removal of command.test has been postponed to November 15.

Everything should work as it did yesterday (with the addition of a new big warning, hopefully).

like image 67
ychiucco Avatar answered Sep 02 '25 23:09

ychiucco


This module was removed from in this commit.

Using setuptools<72.0.0 will alleviate this problem.

Steps you may use once you have sourced the relevant python environment:

# Install setuptools below v72.0.0. Add `-U` after `install` in case you want to upgrade to a version below 72.0.0, if you already have setuptools installed.
python -m pip install 'setuptools<72.0.0'
# Install RandomWords.
python -m pip install RandomWords
like image 35
reza.safiyat Avatar answered Sep 03 '25 00:09

reza.safiyat