Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

python3 -m build gives ModuleNotFoundError: No module named 'pathlib2'

Writer Matthew Martinez

I am trying to build a Python package, but it gives the following error.

* Creating virtualenv isolated environment...
* Installing packages in isolated environment... (setuptools >= 40.8.0, wheel)
* Getting dependencies for sdist...
Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 351, in <module> main() File "/usr/local/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 333, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "/usr/local/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 285, in get_requires_for_build_sdist return hook(config_settings) File "/tmp/build-env-eyqolcf7/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_sdist return self._get_build_requires(config_settings, requirements=[]) File "/tmp/build-env-eyqolcf7/lib/python3.10/site-packages/setuptools/build_meta.py", line 320, in _get_build_requires self.run_setup() File "/tmp/build-env-eyqolcf7/lib/python3.10/site-packages/setuptools/build_meta.py", line 482, in run_setup super(_BuildMetaLegacyBackend, File "/tmp/build-env-eyqolcf7/lib/python3.10/site-packages/setuptools/build_meta.py", line 335, in run_setup exec(code, locals()) File "<string>", line 5, in <module>
ModuleNotFoundError: No module named 'pathlib2'
ERROR Backend subprocess exited when trying to invoke get_requires_for_build_sdist

I have already installed pathlib2. What is the solution?

12

3 Answers

In python 3.9, installing build module solved the problem (it was not there initially).

python -m pip install build

I have successfully build this in Python3.10. pip3.10 freeze gave me this output

 build==0.8.0 packaging==21.3 pep517==0.13.0 pyparsing==3.0.9 tomli==2.0.1

As per the official documentation of the build package, it does not have a stable compatibility

You can try switching to an older version of python (3.9 recommended) and try again, ideally, that should solve the error since in traceback, the error seems to originate from setuptools ( which will be automatically reverted back to an older version with a older python version )

NOTE: You will also need to reinstall build in the new python version

Let me know if you face any issues with it.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.