pip install RandomWords: “No module named ‘setuptools.command.test'”

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?

2

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).

10

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

2

Edit

setuptools 72.0.0 has been yanked

https://pypi.org/project/setuptools/72.0.0/#history

Rerun your pipelines all good now.


This bug arises from changes made to setuptools.command.test in the 72.0.0 update of setuptools. For more details, refer to the setuptools · PyPI page. One of the dependencies used in this repository, Ch00k/ffmpy: Pythonic interface for FFmpeg/FFprobe command line, utilizes setuptools.command.test.

As a temporary solution, I forked the project and removed the relevant code to ensure it runs smoothly. You can use the following command to install the modified version:

pip install git+https://github.com/EuDs63/ffmpy.git

https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/16289#issuecomment-2255106490

option 2

RUN pip3 install -I --force-reinstall setuptools==71.0.0
RUN pip3 install --no-build-isolation --no-cache-dir -r requirements.txt

https://github.com/pypa/setuptools/issues/4519#issuecomment-2255358015

option 3

RUN echo "setuptools<72" > constraints.txt

ENV PIP_CONSTRAINT=constraints.txt

RUN poetry config virtualenvs.create false && 
    poetry run pip install sqlalchemy==1.3.24 && 
    poetry install --no-cache && 

https://github.com/pypa/setuptools/issues/4519#issuecomment-2255446798

option 4

pip3 install --no-build-isolation --no-cache-dir "setuptools<72"

Package version v72.0.0 has just been yanked (https://pypi.org/project/setuptools/72.0.0/).

If you replay your pipelines, the error should no longer pop up.

I’ve got this error too in my Dockerfile.

Workaround:

RUN echo "setuptools<72" > constraints.txt

ENV PIP_CONSTRAINT=constraints.txt

RUN poetry config virtualenvs.create false && 
    poetry run pip install sqlalchemy==1.3.24 && 
    poetry install --no-cache && 

I could not understand why when I degraded the setuptools to version below 72.0.0 it kept cruising with the error of ModuleNotFoundError: No module named 'setuptools.command.test'.

For Poetry users, even locking in setuptools<72 does not [always] seem to work. For some installations it still seems to use setuptools>=72 from somewhere, and the PIP_CONSTRAINT environment variable does not seem to be obeyed by poetry. A workaround here is:

$ poetry export -o requirements.txt
$ poetry export -o constraints.txt -f constraints.txt
$ PIP_CONSTRAINT="$(pwd)/constraints.txt" poetry run pip install -r requirements.txt

In other words, export your locked requirements to traditional pip requirements.txt and constraints.txt files, then run pip in the Poetry environment to install dependencies. This way it properly appears to obey the PIP_CONSTRAINT environment variable.

You can run poetry install afterwards and it should come up with nothing to do, meaning it had exactly the same effect as poetry install.

For the poetry export commands, make sure you add the same arguments as you’d add to poetry install, e.g. --only main.

If pip gives you an error like:

ERROR: Can't verify hashes for these requirements because we don't have a way to hash version control repositories: ...

Then add --without-hashes to the export commands.

Solution/workaround is there : https://github.com/pypa/setuptools/issues/4519

If using docker and PIP or poetry, do the following :

RUN echo "setuptools<72" > constraints.txt
ENV PIP_CONSTRAINT=constraints.txt

(And you can then run your pip/poetry commands as normal)

If not, well, create a file constraints.txt at the root of your project with setuptools<72 as the file content
Then use export PIP_CONSTRAINT=constraints.txt to point to that file in the environnement variables.

Remove the fix once the upstream packages are updated

1

Please install setuptools < 72.0.0 as tmp solution -> run installation for you package/library.

Bit, I think, adding setuptools as a dependency to poetry will work unstable, since all packages are installed in parallel (even in batches) and in this case the build will be non-deterministic (depending on what is installed first, the setup tool or the library)

echo "setuptools<72" > constraints.txt
export PIP_CONSTRAINT=constraints.txt

poetry run pip install <affected_package>==<version>
poetry install

As a temporary workaround, try this:

pip install --upgrade pip-tools pip wheel
pip install setuptools==71.1.0

Run this before installing your packages.

The old version of setuptools has been depricated on 28th July 2024.
New version of setuptool==72.0.0 has bug.
For that you have to add 2 additional things:

  • use setuptools<72.0.0
  • use 1.0=0.40
WORKDIR /app
RUN pip install --upgrade pip
RUN pip install pipenv
RUN python -m pip install 'setuptools<72.0.0'
RUN python -m pip install 'wheel>=0.40,<1.0'
RUN pipenv install --system --dev
RUN pipenv install --system --deploy
EXPOSE 8000

CMD python manage.py runserver --noreload 0.0.0.0:8000

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật