Error processing line 1 of distutils-precedence.pth (no module named '_distutils_hack')
Asked Answered
F

1

8

I'm on Windows 10 and working in a git-bash terminal with anaconda environment. When I open a new terminal, I'm immediately presented with:

Error processing line 1 of C:\Users\e360769\AppData\Local\miniforge3\lib\site-packages\distutils-precedence.pth:

  Traceback (most recent call last):
    File "C:\Users\e360769\AppData\Local\miniforge3\lib\site.py", line 169, in addpackage
      exec(line)
    File "<string>", line 1, in <module>
  ModuleNotFoundError: No module named '_distutils_hack'

Remainder of file ignored

This same error comes up any time I run "pip" or "python" on the command line. The command still executes correctly, but only after displaying that error. Note that this started after installing a collection of packages needed for a project I'm working with, and after investigating I found some people attributed this to the setuptools package (I have v41.2.0), but even when I uninstall it, the issue persists. Also note that this is the contents of my distutils-precedence.pth file:

import os; var = 'SETUPTOOLS_USE_DISTUTILS'; enabled = os.environ.get(var, 'local') == 'local'; enabled and __import__('_distutils_hack').add_shim();

I'm not sure this is actively (for now) causing any issues with executing my python scripts, etc., but I'd like to know what's going on and how to fix this. Would appreciate any help!

Flytrap answered 1/10, 2022 at 16:54 Comment(0)
H
3

In my case, the issue has been resolved just by removing distutils-precedence.pth

$ rm -rf /home/user/anaconda3/lib/python3.10/site-packages/distutils-precedence.pth

I encountered that issue while updating setuptools, and it stopped installation in between that time this error was starting. So later I removed setuptools and reinstalled it again.

Haplography answered 4/7, 2023 at 18:45 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.