readthedocs.org: ModuleNotFoundError: No module named 'setuptools._distutils'
Hi,
We use readthedocs for the jarvis-tools package. Recently, I am seeing an error due to setuptools:
Raw log here: https://readthedocs.org/api/v2/build/15584283.txt
I am wondering if somebody can help me with this.
š Edit by @astrojuanlu š This issue is triggered by setuptools 60, released on 2021-12-19. Current status:
- ~If your project doesnāt have a
pyproject.toml
, most likely you have the āuse system packagesā version enabled. You can (1) disable it, (2) cap setuptools yourself in your requirements, or (3) wait for us to deploy a fix (January 2022) . See below for more context.~ Update: This has been fixed on RTD as of Dec 21. - If your project does have a
pyproject.toml
, most likely pip is using its fallback mode and installing the problematic setuptools version in an isolated environment. In this case, there is nothing Read the Docs can do to fix your problem. You can do it yourself by adding a proper[build-system]
PEP 518 table to yourpyproject.toml
file. See below for more information. - You can temporarily roll back to the old setuptools behavior by exporting a
SETUPTOOLS_USE_DISTUTILS=stdlib
environment variable for your project. However, it is not guaranteed that this will work forever, and we encourage you to look into the solution above. - If you were redirected here, itās because you opened a new issue for this exact problem. Please try the solution above first.
- If it didnāt work, leave a comment below with a link to your failing build.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 23 (6 by maintainers)
Commits related to this issue
- Cap setuptools even if installed packages are ignored See #8775. — committed to readthedocs/readthedocs.org by astrojuanlu 3 years ago
- turn off system packages in .readthedocs.yml — committed to pypsa-meets-earth/pypsa-earth by pz-max 3 years ago
- Cap setuptools even if installed packages are ignored See #8775. — committed to readthedocs/readthedocs.org by astrojuanlu 3 years ago
@uvchik I think your case is slightly different. Since your project has a
pyproject.toml
file, pip triggers a different install mode that performs build isolation:Then, since your
pyproject.toml
does not define build-time dependencies as per PEP 518, pip uses a fallback mode. Therefore, no matter what setuptools version you install in yourrequirements.txt
, and no matter what version we magically install for you, pip will use the newest version that fits the"setuptools>=40.8.0"
pinning. In your case, the problematic setuptools 60.x.The solution in your case is to add the following contents to your
pyproject.toml
:Can you please try it and let us know if it works?
Leaving this issue pinned so folks can easily find it, but we have done our part from the RTD side already to avoid that most projects experience it, so I am closing it. Feel free to continue the conversation here, but remember to read the current status in the first comment before doing so.
Thank you. Works fine.
Added detailed instructions with several methods to fix this issue in the first comment āš½
We were using the system packages because we depend on Matplotlib, scipy, numpy, etc. and wanted to avoid installing them from scratch. But turning off system packages seems to have fixed the issue.
I checked and we had the āuse system packagesā option enabled as well, I donāt recall why. I unchecked it and re-ran the builds and they passed. So that fixed it for us. Thank you!
Oh, of course I understand why. Weāre passing
--upgrade
in the secondpip install
command, so thepip install setuptools<58.3.0
is useless. This will need a fix.