Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module '_distutils_hack' has no attribute 'ensure_shim' #2983

Closed
1 task done
spacexnasa opened this issue Dec 29, 2021 · 7 comments · Fixed by #2984
Closed
1 task done

AttributeError: module '_distutils_hack' has no attribute 'ensure_shim' #2983

spacexnasa opened this issue Dec 29, 2021 · 7 comments · Fixed by #2984
Labels

Comments

@spacexnasa
Copy link

spacexnasa commented Dec 29, 2021

setuptools version

setuptools==60.0.5

Python version

python 3.10

OS

macOS intel 12.1

Additional environment information

No response

Description

python3 -m pip install -U setuptools

Expected behavior

python3 -m pip install -U setuptools

How to Reproduce

brew install python@3.10
python3 -m pip install -U setuptools

Output

Collecting setuptools
  Downloading setuptools-60.1.1-py3-none-any.whl (952 kB)
     |████████████████████████████████| 952 kB 351 kB/s            
Installing collected packages: setuptools
  Attempting uninstall: setuptools
    Found existing installation: setuptools 60.0.5
    Uninstalling setuptools-60.0.5:
      Successfully uninstalled setuptools-60.0.5
Successfully installed setuptools-60.1.1

and when you exit and relogin

Error processing line 1 of /usr/local/Cellar/python@3.10/3.10.1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/distutils-precedence.pth:

  Traceback (most recent call last):
    File "/usr/local/Cellar/python@3.10/3.10.1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site.py", line 186, in addpackage
      exec(line)
    File "<string>", line 1, in <module>
  AttributeError: module '_distutils_hack' has no attribute 'ensure_shim'

Remainder of file ignored

Code of Conduct

  • I agree to follow the PSF Code of Conduct
@spacexnasa spacexnasa added bug Needs Triage Issues that need to be evaluated for severity and status. labels Dec 29, 2021
@spacexnasa
Copy link
Author

i tested the version v60.1.1 and v60.1.0,both same error,only setuptools==60.0.5 can work

@jaraco
Copy link
Member

jaraco commented Dec 29, 2021

Setuptools 60.1 ships with a new _distutils_hack module that does contain that attribute. For some reason, in your environment, there's another _distutils_hack module that's taking precedence, probably from an older Setuptools.

You should be able to run python3.10 -c "import _distutils_hack; print(_distutils_hack.__file__)" to see where that module can be found. Can you do that please and report the output? My guess is you have a user-installed copy in ~/.local.

In theory, loading the shim should be tolerant to configurations like these. In #2962 and #2964, we're exploring some approaches that could limit which .pth files invoke which _hack modules.

@jaraco jaraco added Needs Investigation Issues which are likely in scope but need investigation to figure out the cause and removed Needs Triage Issues that need to be evaluated for severity and status. labels Dec 29, 2021
@jaraco
Copy link
Member

jaraco commented Dec 29, 2021

This issue is likely another manifestation of #2957.

@jaraco jaraco added duplicate and removed duplicate Needs Investigation Issues which are likely in scope but need investigation to figure out the cause labels Dec 29, 2021
@jaraco
Copy link
Member

jaraco commented Dec 29, 2021

Although the issues are similar, the more selective fix for that issue will likely not fix this one, so I'll deal with it separately.

@marcelo321
Copy link

@jaraco,

I am getting this error:

Error processing line 1 of /root/.ebcli-virtual-env/lib/python3.10/site-packages/distutils-precedence.pth:

  Traceback (most recent call last):
    File "/usr/lib/python2.7/site.py", line 158, in addpackage
      exec line
    File "<string>", line 1, in <module>
    File "/root/.ebcli-virtual-env/lib/python3.10/site-packages/_distutils_hack/__init__.py", line 194
      f'spec_for_{name}',
                       ^
  SyntaxError: invalid syntax

@abravalheri
Copy link
Contributor

@marcelo, these parts of your error trace seem to indicated that there is something very wrong going on:

/root/.ebcli-virtual-env/lib/python3.10/
/usr/lib/python2.7/site.py

How can a python2.7 install be using files from a python3.10 virtual env and vice-versa?

@marcelo321
Copy link

Yeah I noticed that, but I don't really know how to fix it haha. I don't know why there is python2.7 there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants