Pip install failed for cchardet with error "ModuleNotFoundError: No module named 'setuptools.py31compat'"

Tried to install cchardet python module but fails with a wierd error w.r.t setuptools module

Collecting cchardet==2.1.7 Using cached cchardet-2.1.7.tar.gz (653 kB) Preparing metadata (setup.py) error error: subprocess-exited-with-error python setup.py egg_info did not run successfully. exit code: 1 [39 lines of output] cythonize: ['src/cchardet/_cchardet.pyx'] running egg_info creating /tmp/pip-pip-egg-info-5x5qahxb/cchardet.egg-info writing /tmp/pip-pip-egg-info-5x5qahxb/cchardet.egg-info/PKG-INFO writing dependency_links to /tmp/pip-pip-egg-info-5x5qahxb/cchardet.egg-info/dependency_links.txt writing top-level names to /tmp/pip-pip-egg-info-5x5qahxb/cchardet.egg-info/top_level.txt writing manifest file '/tmp/pip-pip-egg-info-5x5qahxb/cchardet.egg-info/SOURCES.txt' Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 34, in <module> File "/tmp/pip-wheel-qe4knwhc/cchardet_015ff5c4f63b4591bebdd029bb95c730/setup.py", line 115, in <module> setup( File "/usr/local/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup return distutils.core.setup(**attrs) File "/usr/local/lib/python3.9/distutils/core.py", line 148, in setup dist.run_commands() File "/usr/local/lib/python3.9/distutils/dist.py", line 966, in run_commands self.run_command(cmd) File "/usr/local/lib/python3.9/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/usr/local/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 299, in run self.find_sources() File "/usr/local/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 306, in find_sources mm.run() File "/usr/local/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 541, in run self.add_defaults() File "/usr/local/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 581, in add_defaults rcfiles = list(walk_revctrl()) File "/usr/local/lib/python3.9/site-packages/setuptools/command/sdist.py", line 18, in walk_revctrl for item in ep.load()(dirname): File "/usr/local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 2450, in load return self.resolve() File "/usr/local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 2456, in resolve module = __import__(self.module_name, fromlist=['__name__'], level=0) File "/usr/local/lib/python3.9/site-packages/setuptools_svn/__init__.py", line 6, in <module> from setuptools_svn import svn_utils File "/usr/local/lib/python3.9/site-packages/setuptools_svn/svn_utils.py", line 13, in <module> from setuptools.py31compat import TemporaryDirectory ModuleNotFoundError: No module named 'setuptools.py31compat' [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed Encountered error while generating package metadata. See above for output. note: This is an issue with the package mentioned above, not pip. 

When checked for the presence of 'py31compat.py' in setuptools install directory found 'py34compat.py' instead. Any suggestions on how to overcome this issue

1 Answer

You seem to be using setuptools >= 50 which dropped Python 2.7 support, along with all Python releases under 3.5.

setuptools-svn used to be directly dependent on setuptools.py31compat which has been removed from setuptools in v50. Fortunately, they dropped that import it in 1.3.0.

So you can fix your issue by doing one of the following:

  • Downgrade setuptools to <50
  • Upgrade setuptools-svn to 1.3.0

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.

You Might Also Like