kb icon indicating copy to clipboard operation
kb copied to clipboard

AttributeError: module 'attr' has no attribute 's'

Open almereyda opened this issue 2 years ago • 7 comments

Expected Behavior

kb runs.

Actual Behavior

Executing kb yields:

$ kb
Traceback (most recent call last):
  File "/home/yala/.local/bin/kb", line 5, in <module>
    from kb.main import main
  File "/home/yala/.local/lib/python3.10/site-packages/kb/main.py", line 19, in <module>
    from kb.commands.add import add
  File "/home/yala/.local/lib/python3.10/site-packages/kb/commands/add.py", line 19, in <module>
    import kb.db as db
  File "/home/yala/.local/lib/python3.10/site-packages/kb/db.py", line 21, in <module>
    from kb.entities.artifact import Artifact
  File "/home/yala/.local/lib/python3.10/site-packages/kb/entities/artifact.py", line 18, in <module>
    @attr.s(auto_attribs=True, frozen=True, slots=True)
AttributeError: module 'attr' has no attribute 's'

Steps to Reproduce the Problem

  1. Execute pip install -U kb-manager
  2. Execute kb
  3. See the error above.

Specifications

  • Version: 70eda732c688f0dd1cc3e238b0f87e5042397a7c
  • Platform: Ubuntu 22.04
  • Subsystem: Python 3.10 (system)

almereyda avatar Sep 22 '22 11:09 almereyda

Please give a look at the FAQ section of the README

gnebbia avatar Sep 22 '22 11:09 gnebbia

Ah yes ;) I saw this comment in another issue, why I returned here in the first place.

almereyda avatar Sep 22 '22 11:09 almereyda

Unfortunately on my system running the commands as in

  • https://github.com/gnebbia/kb#faq

does not help:

$ pip uninstall attr attrs
Found existing installation: attr 0.3.2
Uninstalling attr-0.3.2:
  Would remove:
    /home/yala/.local/lib/python3.10/site-packages/attr-0.3.2.dist-info/*
    /home/yala/.local/lib/python3.10/site-packages/attr.py
    /home/yala/.local/lib/python3.10/site-packages/dry_attr.py
Proceed (Y/n)?
  Successfully uninstalled attr-0.3.2
Found existing installation: attrs 21.2.0
Not uninstalling attrs at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'attrs'. No files were found to uninstall.

$ pip install attr
Defaulting to user installation because normal site-packages is not writeable
Collecting attr
  Using cached attr-0.3.2-py2.py3-none-any.whl (3.3 kB)
Installing collected packages: attr
Successfully installed attr-0.3.2

$ pip install -U kb-manager
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: kb-manager in /home/yala/.local/lib/python3.10/site-packages (0.1.7)
Requirement already satisfied: colored in /home/yala/.local/lib/python3.10/site-packages (from kb-manager) (1.4.3)
Requirement already satisfied: gitpython in /home/yala/.local/lib/python3.10/site-packages (from kb-manager) (3.1.27)
Requirement already satisfied: attrs in /usr/lib/python3/dist-packages (from kb-manager) (21.2.0)
Requirement already satisfied: toml in /usr/lib/python3/dist-packages (from kb-manager) (0.10.2)
Requirement already satisfied: attr in /home/yala/.local/lib/python3.10/site-packages (from kb-manager) (0.3.2)
Requirement already satisfied: gitdb<5,>=4.0.1 in /home/yala/.local/lib/python3.10/site-packages (from gitpython->kb-manager) (4.0.9)
Requirement already satisfied: smmap<6,>=3.0.1 in /home/yala/.local/lib/python3.10/site-packages (from gitdb<5,>=4.0.1->gitpython->kb-manager) (5.0.0)

$ kb list
Traceback (most recent call last):
  File "/home/yala/.local/bin/kb", line 5, in <module>
    from kb.main import main
  File "/home/yala/.local/lib/python3.10/site-packages/kb/main.py", line 19, in <module>
    from kb.commands.add import add
  File "/home/yala/.local/lib/python3.10/site-packages/kb/commands/add.py", line 19, in <module>
    import kb.db as db
  File "/home/yala/.local/lib/python3.10/site-packages/kb/db.py", line 21, in <module>
    from kb.entities.artifact import Artifact
  File "/home/yala/.local/lib/python3.10/site-packages/kb/entities/artifact.py", line 18, in <module>
    @attr.s(auto_attribs=True, frozen=True, slots=True)
AttributeError: module 'attr' has no attribute 's'

Please note that attrs (with s) has not been uninstalled, since it derives from the system installation and is outside of the /usr (as it says, despite being in /usr; well).

This might be an issue with my Python environment, after all. I should try reproducing this within a dedicated pyenv, Poetry, conda or asdf environment.

almereyda avatar Sep 22 '22 11:09 almereyda

Wait there is no attrs installed? Yes please retry with a clean environment.

gnebbia avatar Sep 22 '22 12:09 gnebbia

Apparently, attrs is installed, but cannot be deleted (due to the lack of sudo):

Found existing installation: attrs 21.2.0
Not uninstalling attrs at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'attrs'. No files were found to uninstall.

Working with a dedicated environment seems advisable here, as you suggest.

almereyda avatar Sep 22 '22 14:09 almereyda

Still / again an issue:

]$ uname -a
Linux drew-northup.unet.maine.edu 6.8.11-200.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Sun May 26 20:05:41 UTC 2024 x86_64 GNU/Linux
]$ python3 --version
Python 3.12.3

Working with a dedicated environment for this one tool is not a viable solution—especially considering its purpose. I'm wondering if this is a python bug, as my system has attr and attrs both installed, one via local pip and the other via the system. (Path segments hidden with ....... )

]$ kbl
Traceback (most recent call last):
  File "/home/......./.local/bin/kb", line 5, in <module>
    from kb.main import main
  File "/home/......./.local/lib/python3.12/site-packages/kb/main.py", line 19, in <module>
    from kb.commands.add import add
  File "/home/......./.local/lib/python3.12/site-packages/kb/commands/add.py", line 19, in <module>
    import kb.db as db
  File "/home/......./.local/lib/python3.12/site-packages/kb/db.py", line 21, in <module>
    from kb.entities.artifact import Artifact
  File "/home/......./.local/lib/python3.12/site-packages/kb/entities/artifact.py", line 18, in <module>
    @attr.s(auto_attribs=True, frozen=True, slots=True)
     ^^^^^^
AttributeError: module 'attr' has no attribute 's'
]$ pip uninstall attrs
Found existing installation: attrs 23.1.0
ERROR: Cannot uninstall attrs 23.1.0, RECORD file not found. Hint: The package was installed by rpm.
]$ pip uninstall attr
Found existing installation: attr 0.3.2
Uninstalling attr-0.3.2:
  Would remove:
    /home/......./.local/lib/python3.12/site-packages/attr-0.3.2.dist-info/*
    /home/......./.local/lib/python3.12/site-packages/attr.py
    /home/......./.local/lib/python3.12/site-packages/dry_attr.py
Proceed (Y/n)? y
  Successfully uninstalled attr-0.3.2
]$ pip install --user attrs
Requirement already satisfied: attrs in /usr/lib/python3.12/site-packages (23.1.0)
]$ pip install attr
Defaulting to user installation because normal site-packages is not writeable
Collecting attr
  Obtaining dependency information for attr from https://files.pythonhosted.org/packages/68/eb/e96c25f5accb24b151c5a559961f29af2ef089725b547efb185985c73e10/attr-0.3.2-py2.py3-none-any.whl.metadata
  Using cached attr-0.3.2-py2.py3-none-any.whl.metadata (1.2 kB)
Using cached attr-0.3.2-py2.py3-none-any.whl (3.3 kB)
Installing collected packages: attr
Successfully installed attr-0.3.2

dnorthup-ums avatar Jun 28 '24 16:06 dnorthup-ums

Verified: There's something off about python3 the way it is "shipped" by Fedora

With attr installed:

]$ python3
Python 3.12.3 (main, Apr 17 2024, 00:00:00) [GCC 13.2.1 20240316 (Red Hat 13.2.1-7)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import attrs
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.12/site-packages/attrs/__init__.py", line 3, in <module>
    from attr import (
ImportError: cannot import name 'NOTHING' from 'attr' (/home/dnorthup/.local/lib/python3.12/site-packages/attr.py)
>>> quit
Use quit() or Ctrl-D (i.e. EOF) to exit
>>> 

(uninstall attr via pip)

[dnorthup@drew-northup ~]$ python3
Python 3.12.3 (main, Apr 17 2024, 00:00:00) [GCC 13.2.1 20240316 (Red Hat 13.2.1-7)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import attrs
>>> quit
Use quit() or Ctrl-D (i.e. EOF) to exit
>>>

dnorthup-ums avatar Jun 28 '24 16:06 dnorthup-ums