question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] KeyError: 'unix_user' with setuptools 60.0.0

See original GitHub issue

setuptools version

setuptools-60.0.0

Python version

Python 3.9

OS

Ubuntu 18.04

Additional environment information

No response

Description

Getting this error with setuptools 60.0.0

Traceback (most recent call last): File β€œ<string>”, line 1, in <module> File β€œ/tmpfs/src/github/jax/setup.py”, line 31, in <module> setup( File β€œ/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/init.py”, line 153, in setup return distutils.core.setup(**attrs) File β€œ/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/_distutils/core.py”, line 148, in setup return run_commands(dist) File β€œ/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/_distutils/core.py”, line 163, in run_commands dist.run_commands() File β€œ/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/_distutils/dist.py”, line 967, in run_commands self.run_command(cmd) File β€œ/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/_distutils/dist.py”, line 985, in run_command cmd_obj.ensure_finalized() File β€œ/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/_distutils/cmd.py”, line 107, in ensure_finalized self.finalize_options() File β€œ/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/command/develop.py”, line 52, in finalize_options easy_install.finalize_options(self) File β€œ/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/command/easy_install.py”, line 263, in finalize_options self._fix_install_dir_for_user_site() File β€œ/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/command/easy_install.py”, line 375, in _fix_install_dir_for_user_site self.select_scheme(scheme_name) File β€œ/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/command/easy_install.py”, line 716, in select_scheme scheme = INSTALL_SCHEMES[name] KeyError: β€˜unix_user’ ---------------------------------------- ERROR: Command errored out with exit status 1: /usr/local/bin/python3.9 -c β€˜import io, os, sys, setuptools, tokenize; sys.argv[0] = β€˜"’"’/tmpfs/src/github/jax/setup.pyβ€™β€œ'β€β€˜; file=β€™β€œ'β€β€˜/tmpfs/src/github/jax/setup.pyβ€™β€œ'β€β€˜;f = getattr(tokenize, β€˜"β€™β€œβ€˜openβ€™β€β€™β€œβ€˜, open)(file) if os.path.exists(file) else io.StringIO(β€™β€β€˜β€œβ€˜from setuptools import setup; setup()β€™β€β€™β€œβ€˜);code = f.read().replace(β€™β€β€˜"’\r\nβ€™β€œ'β€β€˜, β€˜"’"’\nβ€™β€œ'β€β€˜);f.close();exec(compile(code, file, β€˜"β€™β€œβ€˜exec’”’"β€˜))’ develop --no-deps --user --prefix= Check the logs for full command output.

Expected behavior

The Error should not happen. It was working fine with setuptools 59.8.0

How to Reproduce

  1. git clone https://github.com/google/jax.git
  2. cd jax
  3. python3.9 -m pip install -e .

Make sure the setuptools version in 60.0.0

Output

Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmpfs/src/github/jax/setup.py", line 31, in <module>
        setup(
      File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
        return distutils.core.setup(**attrs)
      File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 148, in setup
        return run_commands(dist)
      File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 163, in run_commands
        dist.run_commands()
      File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 967, in run_commands
        self.run_command(cmd)
      File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 985, in run_command
        cmd_obj.ensure_finalized()
      File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 107, in ensure_finalized
        self.finalize_options()
      File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/command/develop.py", line 52, in finalize_options
        easy_install.finalize_options(self)
      File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/command/easy_install.py", line 263, in finalize_options
        self._fix_install_dir_for_user_site()
      File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/command/easy_install.py", line 375, in _fix_install_dir_for_user_site
        self.select_scheme(scheme_name)
      File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/command/easy_install.py", line 716, in select_scheme
        scheme = INSTALL_SCHEMES[name]
    KeyError: 'unix_user'
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmpfs/src/github/jax/setup.py'"'"'; __file__='"'"'/tmpfs/src/github/jax/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix= Check the logs for full command output.

Code of Conduct

  • I agree to follow the PSF Code of Conduct

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
mxmlnkncommented, Jul 16, 2022

I still have this problem on Ubuntu 22.04 with Python 3.10 and setuptools 63.2.0 installed. Is that normal?

Edit: I tried a lot of different versions of setuptools: 59,60,61,63 and none works. It works when using python3 setup.py develop --user instead of python3 -m pip install --user --editable.

Note that I also have to use the site.ENABLE_USER_SITE = "--user" in sys.argv[1:] workaround described in this pip issue. It seems to me like installing a development version becomes increasingly impossible.

Obtaining file:///projects/ratarmount/worktrees/1/core
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Installing collected packages: ratarmountcore
  Running setup.py develop for ratarmountcore
    error: subprocess-exited-with-error
    
    Γ— python setup.py develop did not run successfully.
    β”‚ exit code: 1
    ╰─> [29 lines of output]
        running develop
        /usr/lib/python3/dist-packages/setuptools/command/easy_install.py:158: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
          warnings.warn(
        Traceback (most recent call last):
          File "<string>", line 2, in <module>
          File "<pip-setuptools-caller>", line 34, in <module>
          File "/projects/ratarmount/worktrees/1/core/setup.py", line 11, in <module>
            setup()
          File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 153, in setup
            return distutils.core.setup(**attrs)
          File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 148, in setup
            return run_commands(dist)
          File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 163, in run_commands
            dist.run_commands()
          File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 967, in run_commands
            self.run_command(cmd)
          File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 985, in run_command
            cmd_obj.ensure_finalized()
          File "/usr/lib/python3/dist-packages/setuptools/_distutils/cmd.py", line 107, in ensure_finalized
            self.finalize_options()
          File "/usr/lib/python3/dist-packages/setuptools/command/develop.py", line 52, in finalize_options
            easy_install.finalize_options(self)
          File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 270, in finalize_options
            self._fix_install_dir_for_user_site()
          File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 400, in _fix_install_dir_for_user_site
            self.select_scheme(scheme_name)
          File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 741, in select_scheme
            scheme = INSTALL_SCHEMES[name]
        KeyError: 'unix_user'
        [end of output]
    
    note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

Γ— python setup.py develop did not run successfully.
β”‚ exit code: 1
╰─> [29 lines of output]
    running develop
    /usr/lib/python3/dist-packages/setuptools/command/easy_install.py:158: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    Traceback (most recent call last):
      File "<string>", line 2, in <module>
      File "<pip-setuptools-caller>", line 34, in <module>
      File "/projects/ratarmount/worktrees/1/core/setup.py", line 11, in <module>
        setup()
      File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 153, in setup
        return distutils.core.setup(**attrs)
      File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 148, in setup
        return run_commands(dist)
      File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 163, in run_commands
        dist.run_commands()
      File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 967, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 985, in run_command
        cmd_obj.ensure_finalized()
      File "/usr/lib/python3/dist-packages/setuptools/_distutils/cmd.py", line 107, in ensure_finalized
        self.finalize_options()
      File "/usr/lib/python3/dist-packages/setuptools/command/develop.py", line 52, in finalize_options
        easy_install.finalize_options(self)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 270, in finalize_options
        self._fix_install_dir_for_user_site()
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 400, in _fix_install_dir_for_user_site
        self.select_scheme(scheme_name)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 741, in select_scheme
        scheme = INSTALL_SCHEMES[name]
    KeyError: 'unix_user'
    [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
0reactions
CroMarmotcommented, Sep 10, 2022

it always working correctly in venv in my system

as for it will remove python3-pip when purging python3-setuptools, I’ve tried some weird way to solve it, and it works in docker

docker run -it --rm ubuntu /bin/bash
apt update && apt install python3 python3-pip -y
useradd -m demouser
su demouser
pip list --outdated
        Package    Version Latest Type
        ---------- ------- ------ -----
        pip        22.0.2  22.2.2 wheel
        setuptools 59.6.0  65.3.0 wheel
pip install --upgrade pip setuptools
        Defaulting to user installation because normal site-packages is not writeable
        Requirement already satisfied: pip in /usr/lib/python3/dist-packages (22.0.2)
        Collecting pip
          Downloading pip-22.2.2-py3-none-any.whl (2.0 MB)
             ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.0/2.0 MB 94.0 kB/s eta 0:00:00
        Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (59.6.0)
        Collecting setuptools
          Downloading setuptools-65.3.0-py3-none-any.whl (1.2 MB)
             ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 78.1 kB/s eta 0:00:00
        Installing collected packages: setuptools, pip
          WARNING: The scripts pip, pip3 and pip3.10 are installed in '/home/demouser/.local/bin' which is not on PATH.
          Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
        Successfully installed pip-22.2.2 setuptools-65.3.0
exit
apt purge python3-pip -y && apt autoremove -y
pip list
        bash: pip: command not found
su demouser
export PATH=~/.local/bin:$PATH
pip list
        Package    Version
        ---------- -------
        pip        22.2.2
        setuptools 65.3.0

docker ubuntu version: ubuntu@sha256:20fa2d7bb4de7723f542be5923b06c4d704370f0390e4ae9e1c833c8785644c1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python distutils keyError - setuptools - Stack Overflow
I downgraded to setuptools==58.2.0 and now it works fine again.
Read more >
Bug#1015888: pypi2deb: ps2dsp fails with "KeyError: 'releases'"
Package: pypi2deb. Version: 3.20220721. Severity: normal. Hi. I get $ py2dsp -v pystow. D: py2dsp py2dsp:156: version: 3.20220707
Read more >
Setuptools - PyPI
Easily download, build, install, upgrade, and uninstall Python packages.
Read more >
History - setuptools 65.6.3.post20221216 documentation
#2940: Avoid KeyError in distutils hack when pip is imported during ensurepip. ... #1994: Fixed a bug in the β€œsetuptools.finalize_distribution_options” hookΒ ...
Read more >
python _distutils_hack | The AI Search Engine You Control
It's used by setuptools to replace the stdlib distutils with setuptools' ... to the project and the confirmed the bug was introduced in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found