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

import attr from attrs imports wrong package #1210

Closed
radekzc opened this issue Dec 13, 2023 · 7 comments
Closed

import attr from attrs imports wrong package #1210

radekzc opened this issue Dec 13, 2023 · 7 comments

Comments

@radekzc
Copy link

radekzc commented Dec 13, 2023

2023-12-13 19:48:09.894 [info] from lsprotocol import types as lsp
File "/home/svobora/.vscode-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/lsprotocol/types.py", line 14, in
import attrs
File "/home/svobora/.vscode-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/attrs/init.py", line 3, in
from attr import (
ImportError: cannot import name 'AttrsInstance' from 'attr' (/usr/lib/python3/dist-packages/attr/init.py)

It imports attr package from system python folder (Ubuntu 22.04). What to do?

@hynek
Copy link
Member

hynek commented Dec 29, 2023

OK, I'm sorry, but how are we supposed to help you with that? It seems to be a packaging issue, caused by a VS Code extension that seems to bundle attrs!? My best suggestion is to reinstall ms-python.pylint whose installation seems to be corrupted.

@hynek
Copy link
Member

hynek commented Dec 29, 2023

There's also this: microsoft/vscode-pylint#386

@radekzc
Copy link
Author

radekzc commented Dec 29, 2023

For the starters do not name your packages the same as already existing packages, especially if those are installed as part of mainstream operating systems.

@hynek
Copy link
Member

hynek commented Dec 29, 2023

What package would that be?

@radekzc
Copy link
Author

radekzc commented Dec 29, 2023

attr (not attrs) and removing import attr from your package

@radekzc
Copy link
Author

radekzc commented Dec 29, 2023

https://pypi.org/project/attr/

Attrs should shadow it with its own attr package but it is not working. I suggest not naming a package with a same name as another package in pip.

@hynek
Copy link
Member

hynek commented Dec 29, 2023

Have you double-checked it's actually that package?

On Ubuntu it is not:

$ egrep '(title|author)' /usr/lib/python3/dist-packages/attr/__init__.py
__title__ = "attrs"
__author__ = "Hynek Schlawack"

@hynek hynek closed this as not planned Won't fix, can't repro, duplicate, stale Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants