Search code examples
python-3.xpackageubuntu-22.04ros2colcon

import distutils.command.bdist_wininst as orig


Everything went well while I was trying to create a ros 2 package in Ubuntu 22.04 by following the ros2 documentation, however when I got to the colcon build step, it failed for python packages even though it works for cMake packages.

colcon build --packages-select mypkgpython
...
import distutils.command.bdist_wininst as orig
ModuleNotFoundError: No module named 'distutils.command.bdist_wininst'

knowing that my python version is:

python3 --version
Python 3.10.6

i have tried: sudo apt-get install python3-distutils:

python3-distutils is already the newest version (3.10.6-1~22.04).

sudo apt-get install python3-apt:

python3-apt is already the newest version (2.4.0).

sudo apt install python3-colcon-common-extensions

python3-colcon-common-extensions is already the newest version(0.3.0-1)

how can i solve this problem?

i expected when i build my python package using

colcon build package

it will be successfully build, so i could work with


Solution

  • The bdist_wininst format was deprecated in Python 3.8, and the documentation for this format has been removed in Python 3.9. The recommended way to distribute Python packages now is the Wheel format.

    you can overcome this error by JUST updating the setuptools

    pip install --upgrade setuptools

    Note that: Setuptools version 58.2.0 is the last version that works with ROS 2 python packages without any warnings because it is the last version that supports the old installation method, "python setup.py install." This method has been deprecated and replaced by newer, standards-based tools, such as pip and ament.

    pip install setuptools==58.2.0