No module named 'setuptools.command.build'

I am trying to install Plone 5.2.12 using python 3.8. But encountered this stuptools.command.build not found error and unable to solve it. I'm using Ubuntu 18.04, My system has python 3.6, python 3.8, python 2.7.x versions in my OS. Please help me in solving this issue.

Creating Python virtual environment.
Installing Python requirements in virtual environment.
Create buildout: standalone
Requires-Python support missing and could not be patched into zc.buildout.

Traceback (most recent call last):
File "/home/webadmin/Plone/zinstance/lib/python3.8/site-packages/zc/buildout/patches.py", line 58, in patch_PackageIndex
from pip._internal.index.collector import IndexContent
ModuleNotFoundError: No module named 'pip._internal'

ModuleNotFoundError: No module named 'setuptools.command.build'
An error occurred when trying to install /home/webadmin/Plone/buildout-cache/downloads/dist/zc.recipe.egg-2.0.7.tar.gz. Look above this message for any errors that were output by pip install.
Buildout failed. Unable to continue

This is the error I am getting

prerequisite

mkdir -p /tmp/p5
cd /tmp/p5
python3.8 -m venv ./venv
source venv/bin/activate
wget https://dist.plone.org/release/5.2.12/requirements.txt
pip install -r requirements.txt

or

mkdir -p /tmp/p5
cd /tmp/p5
python3.8 -m venv ./venv
source venv/bin/activate
pip install setuptools==65.7.0
pip install zc.buildout==3.0.1
pip install wheel==0.38.4

create a minimal buildout.cfg

touch buildout.cfg && vim buildout.cfg
[buildout]
extends =
     https://dist.plone.org/release/5.2.12/versions.cfg   

parts +=
    instance

[instance]
recipe = plone.recipe.zope2instance
user = admin:admin
http-address = 8080
eggs =
    Plone
    Pillow

run buildout

buildout

Thanks a lot for the detailed explanation. I followed the same steps, but got the same error. The error is got while Getting distribution for 'zc.recipe.egg==2.0.7'.
The error is

Exception:
Traceback (most recent call last):
  File "/tmp/p5/venv/lib/python3.8/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/tmp/p5/venv/lib/python3.8/site-packages/pip/commands/install.py", line 356, in run
    requirement_set.install(
  File "/tmp/p5/venv/lib/python3.8/site-packages/pip/req/req_set.py", line 780, in install
    requirement.install(
  File "/tmp/p5/venv/lib/python3.8/site-packages/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/tmp/p5/venv/lib/python3.8/site-packages/pip/req/req_install.py", line 1057, in move_wheel_files
    move_wheel_files(
  File "/tmp/p5/venv/lib/python3.8/site-packages/pip/wheel.py", line 245, in move_wheel_files
    scheme = distutils_scheme(
  File "/tmp/p5/venv/lib/python3.8/site-packages/pip/locations.py", line 153, in distutils_scheme
    i.finalize_options()
  File "/tmp/p5/venv/share/python-wheels/setuptools-39.0.1-py2.py3-none-any.whl/setuptools/command/install.py", line 38, in finalize_options
    orig.install.finalize_options(self)
  File "/usr/lib/python3.8/distutils/command/install.py", line 388, in finalize_options
    self.set_undefined_options('build',
  File "/usr/lib/python3.8/distutils/cmd.py", line 286, in set_undefined_options
    src_cmd_obj = self.distribution.get_command_obj(src_cmd)
  File "/usr/lib/python3.8/distutils/dist.py", line 857, in get_command_obj
    klass = self.get_command_class(command)
  File "/tmp/p5/venv/share/python-wheels/setuptools-39.0.1-py2.py3-none-any.whl/setuptools/dist.py", line 634, in get_command_class
    self.cmdclass[command] = cmdclass = ep.load()
  File "/tmp/p5/venv/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2324, in load
    return self.resolve()
  File "/tmp/p5/venv/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2330, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
ModuleNotFoundError: No module named 'setuptools.command.build'
An error occurred when trying to install /tmp/tmpp864j3oxget_dist/zc.recipe.egg-2.0.7.tar.gz. Look above this message for any errors that were output by pip install.

Vlnni via Plone Community wrote at 2023-6-22 09:09 +0000:

Thanks a lot for the detailed explanation. I followed the same steps, but got the same error. The error is got while Getting distribution for 'zc.recipe.egg==2.0.7'.
The error is

2345d00b983a04ebf00a401fb695f4e6d3
Exception:
Traceback (most recent call last):
...
return self.resolve()
File "/tmp/p5/venv/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/init.py", line 2330, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
ModuleNotFoundError: No module named 'setuptools.command.build'

This looks like an incompatibility between setuptools and zc.buildout
(or a broken setuptools installation).

Check with pip show the versions of setuptools and zc.buildout;
verify that those versions are mentoned in Plone's requirements.txt.

I have updated my comment, see the versions of zc.buildout, setuptools and wheel

Thank you,
I have pip 23.1.2 in my machine.

pip 23.1.2 from /home/webadmin/.local/lib/python3.8/site-packages/pip (python 3.8)

But whenever I create a virtual environment, I get default pip version 9.0.1.

The minimal buildout.cfg worked when I upgraded my pip from 9.0.1 to 23.1.2 in virtual environment.
When I install Plone 5.2.12 with ./install.sh, plone itself creates a virtual environment with our python3.8, while creating the environment it is also creating a pip default 9.0.1 version, and thus the above errors are occured and the installation stops. We can't interrupt the installation process and upgrade and run it again.

Is their a method where by creating virtualenv we get default pip of higher version.

When I run sudo apt install python3-pip I get the below message as 9.0.1 is installed.

Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-pip is already the newest version (9.0.1-2.3~ubuntu1.18.04.8).

Hello, Thanks a lot, changed the pip version and the plone version 5.2.12 installed with python version 3.8

Our website is hosted on plone since three years. I have updated the version from 5.2.0 to 5.2.12. But the backend is python2.7 itself. Now, I need to migrate the data layer from python2.7 to python3.8.

I assumed after installing plone with pyhton3.8 and version 5.2.12, moving the var/ folder which includes blobstorage will do the job. I removed the initial var/ folder of python3.8 setup and replaced with the old var/ folder which consists of three years data. But after running bin/buildout and starting plone with bin/plonectl start, the plone is not running and show this site can't be reached. Please help me in migrating plone. Thanks and Regards

Please read the docs for a migration and please Backup Your Data.fs before you begin :wink:
https://5.docs.plone.org/manage/upgrading/version_specific_migration/upgrade_to_python3.html
https://5.docs.plone.org/manage/upgrading/version_specific_migration/upgrade_zodb_to_python3.html