AttributeError: 'Distribution' object has no attribute'_referenced_files

Good day all

Trying to fix an install-procedure on Ubuntu 20.04

I have already fixed some errors:
When cryptography was installed in broke pip : managed to fix that by editing this file
and commenting out the line CB_ISSUER…
and then running
sudo -H python3 -m pip install --upgrade setuptools cryptography==36.0.2 psutil

At the point where I do
sudo pip3 install -e /home/erpnext/.bench
I got an invalid version error which I fixed with …
sudo pip install --upgrade --user setuptools==58.3.0

But then in that same command , after fixing that, I now get

erpnext@ubuntu-s-2vcpu-4gb-sfo2-01-scaleway:~$ sudo pip3 install -e /home/erpnext/.bench
/usr/lib/python3/dist-packages/secretstorage/ CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes instead
from cryptography.utils import int_from_bytes
/usr/lib/python3/dist-packages/secretstorage/ CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes instead
from cryptography.utils import int_from_bytes
Obtaining file:///home/erpnext/.bench
Requirement already satisfied: Click==7.0 in /usr/lib/python3/dist-packages (from bench==5.0.0) (7.0)
/usr/local/lib/python3.8/dist-packages/cryptography/hazmat/backends/openssl/ CryptographyDeprecationWarning: This version of cryptography contains a temporary pyOpenSSL fallback path. Upgrade pyOpenSSL now.
Collecting GitPython==2.1.15
Downloading GitPython-2.1.15-py2.py3-none-any.whl (452 kB)
|████████████████████████████████| 452 kB 28.9 MB/s
Collecting honcho==1.0.1
Downloading honcho-1.0.1-py2.py3-none-any.whl (21 kB)
Collecting Jinja2==2.10.3
Downloading Jinja2-2.10.3-py2.py3-none-any.whl (125 kB)
|████████████████████████████████| 125 kB 62.6 MB/s
Collecting python-crontab==2.4.0
Downloading python-crontab-2.4.0.tar.gz (50 kB)
|████████████████████████████████| 50 kB 7.6 MB/s
Requirement already satisfied: requests==2.22.0 in /usr/lib/python3/dist-packages (from bench==5.0.0) (2.22.0)
Collecting semantic-version==2.8.2
Downloading semantic_version-2.8.2-py2.py3-none-any.whl (15 kB)
Collecting setuptools==40.8.0
Downloading setuptools-40.8.0-py2.py3-none-any.whl (575 kB)
|████████████████████████████████| 575 kB 38.6 MB/s
Collecting six==1.12.0
Downloading six-1.12.0-py2.py3-none-any.whl (10 kB)
Collecting virtualenv==16.6.0
Downloading virtualenv-16.6.0-py2.py3-none-any.whl (2.0 MB)
|████████████████████████████████| 2.0 MB 49.6 MB/s
Collecting gitdb2<3,>=2
Downloading gitdb2-2.0.6-py2.py3-none-any.whl (63 kB)
|████████████████████████████████| 63 kB 4.6 MB/s
Requirement already satisfied: MarkupSafe>=0.23 in /usr/lib/python3/dist-packages (from Jinja2==2.10.3->bench==5.0.0) (1.1.0)
Collecting python-dateutil
Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
|████████████████████████████████| 247 kB 44.5 MB/s
Collecting smmap2>=2.0.0
Downloading smmap2-3.0.1-py3-none-any.whl (1.1 kB)
Collecting smmap>=3.0.1
Downloading smmap-5.0.0-py3-none-any.whl (24 kB)
Building wheels for collected packages: python-crontab
Building wheel for python-crontab ( … done
Created wheel for python-crontab: filename=python_crontab-2.4.0-py3-none-any.whl size=25182 sha256=8babe20e187d936aecf2c2ecc54c657723cc9e49d487ea033e8beff6381c1228
Stored in directory: /root/.cache/pip/wheels/1d/82/3a/f44a0ec7d3d594f75725488c0a08136371956e527cac140861
Successfully built python-crontab
Installing collected packages: smmap, smmap2, gitdb2, GitPython, honcho, Jinja2, six, python-dateutil, python-crontab, semantic-version, setuptools, virtualenv, bench
Attempting uninstall: Jinja2
Found existing installation: Jinja2 2.10.1
Not uninstalling jinja2 at /usr/lib/python3/dist-packages, outside environment /usr
Can’t uninstall ‘Jinja2’. No files were found to uninstall.
Attempting uninstall: six
Found existing installation: six 1.14.0
Not uninstalling six at /usr/lib/python3/dist-packages, outside environment /usr
Can’t uninstall ‘six’. No files were found to uninstall.
Attempting uninstall: setuptools
Found existing installation: setuptools 58.3.0
Uninstalling setuptools-58.3.0:
Successfully uninstalled setuptools-58.3.0
Running develop for bench
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/home/erpnext/.bench/’“'”‘; file=’“'”‘/home/erpnext/.bench/’“'”‘;f=getattr(tokenize, ‘"’“‘open’”’“‘, open)(file);’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ develop --no-deps
cwd: /home/erpnext/.bench/
Complete output (23 lines):
/usr/local/lib/python3.8/dist-packages/setuptools/ SetuptoolsDeprecationWarning: As setuptools moves its configuration towards pyproject.toml,
setuptools.config.parse_configuration became deprecated.

For the time being, you can use the `setuptools.config.setupcfg` module
to access a backward compatible API, but this module is provisional
and might be removed in the future.

  parse_configuration(self, self.command_options,
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/erpnext/.bench/", line 14, in <module>
  File "/usr/local/lib/python3.8/dist-packages/setuptools/", line 144, in setup
  File "/usr/local/lib/python3.8/dist-packages/setuptools/", line 137, in _install_setup_requires
  File "/usr/local/lib/python3.8/dist-packages/setuptools/", line 704, in parse_config_files
    parse_configuration(self, self.command_options,
  File "/usr/local/lib/python3.8/dist-packages/setuptools/config/", line 29, in _wrapper
    return fn(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/setuptools/config/", line 176, in parse_configuration
AttributeError: 'Distribution' object has no attribute '_referenced_files'

I have googled … but no answer yet…
Would appreciate some assistance


It seems I should have combined the two “Fixes”…

Instead of
sudo -H python3 -m pip install --upgrade setuptools cryptography==36.0.2 psutil
sudo pip install --upgrade --user setuptools==58.3.0

rather do…
sudo -H python3 -m pip install --upgrade setuptools==58.3.0 cryptography==36.0.2 psutil

error does not come up again…