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

Python 3.11 ImportError: cannot import name 'formatargspec' from 'inspect' (pylint) #239

Open
lilymooncake opened this issue Jun 14, 2023 · 9 comments

Comments

@lilymooncake
Copy link

lilymooncake commented Jun 14, 2023

  • Version: Fresh install from pip 1.15.0
  • Python: 3.11
  • OS: OSX Ventura 13.0 - 2023 Macbook Pro - M2 Chip 16GB Memory

logs below

Traceback (most recent call last):
  File "/Users/summer/.cache/pre-commit/reponeoe_8g3/py_env-python3.11/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
             ^^^^^^^^^^^^
  File "/Users/summer/.cache/pre-commit/reponeoe_8g3/py_env-python3.11/lib/python3.11/site-packages/pylint/__init__.py", line 21, in run_pylint
    from pylint.lint import Run as PylintRun
  File "/Users/summer/.cache/pre-commit/reponeoe_8g3/py_env-python3.11/lib/python3.11/site-packages/pylint/lint/__init__.py", line 75, in <module>
    from pylint.lint.parallel import check_parallel
  File "/Users/summer/.cache/pre-commit/reponeoe_8g3/py_env-python3.11/lib/python3.11/site-packages/pylint/lint/parallel.py", line 7, in <module>
    from pylint import reporters
  File "/Users/summer/.cache/pre-commit/reponeoe_8g3/py_env-python3.11/lib/python3.11/site-packages/pylint/reporters/__init__.py", line 25, in <module>
    from pylint import utils
  File "/Users/summer/.cache/pre-commit/reponeoe_8g3/py_env-python3.11/lib/python3.11/site-packages/pylint/utils/__init__.py", line 45, in <module>
    from pylint.utils.ast_walker import ASTWalker
  File "/Users/summer/.cache/pre-commit/reponeoe_8g3/py_env-python3.11/lib/python3.11/site-packages/pylint/utils/ast_walker.py", line 6, in <module>
    from astroid import nodes
  File "/Users/summer/.cache/pre-commit/reponeoe_8g3/py_env-python3.11/lib/python3.11/site-packages/astroid/__init__.py", line 48, in <module>
    import wrapt
  File "/Users/summer/.cache/pre-commit/reponeoe_8g3/py_env-python3.11/lib/python3.11/site-packages/wrapt/__init__.py", line 10, in <module>
    from .decorators import (adapter_factory, AdapterFactory, decorator,
  File "/Users/summer/.cache/pre-commit/reponeoe_8g3/py_env-python3.11/lib/python3.11/site-packages/wrapt/decorators.py", line 34, in <module>
    from inspect import ismethod, isclass, formatargspec
ImportError: cannot import name 'formatargspec' from 'inspect' (/opt/homebrew/Cellar/[email protected]/3.11.4/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py)
@lilymooncake
Copy link
Author

my workaround: go to => site-packages/wrapt/decorators.py and change all "formatargspec" to "formatargvalues"

@GrahamDumpleton
Copy link
Owner

You look to be using an old wrapt version. Are you pinning the version? You need to be using at least wrapt 1.14.0 if using Python 3.11.

@lilymooncake
Copy link
Author

lilymooncake commented Jun 14, 2023

@GrahamDumpleton I updated the version information that I've used (which is 1.15.0)

@GrahamDumpleton
Copy link
Owner

And are you suggesting that it still fails with 1.15.0, or does it now work?

@lilymooncake
Copy link
Author

Hi Graham, I went to site-packages/wrapt/decorators.py and change all "formatargspec" to "formatargvalues"

@GrahamDumpleton
Copy link
Owner

That isn't what I am asking. I am asking for clarification that if you ensure you are using version 1.15.0 that still had the issue.

The traceback you give above is not for when using version 1.15.0.

The trackback shows:

  File "/Users/summer/.cache/pre-commit/reponeoe_8g3/py_env-python3.11/lib/python3.11/site-packages/wrapt/decorators.py", line 34, in <module>
    from inspect import ismethod, isclass, formatargspec
ImportError: cannot import name 'formatargspec' from 'inspect' (/opt/homebrew/Cellar/[email protected]/3.11.4/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py)

But line 34 in version 1.15.0 (latest) doesn't look like that, so you must be on an older version. See what latest code looks like at:

which should show:

from inspect import isclass
from threading import Lock, RLock

from .arguments import formatargspec

So it doesn't import formatargspec from inspect, but uses a local version.

@GrahamDumpleton
Copy link
Owner

I would suggest you pip uninstall wrapt and re-install it with latest to make sure is replacing older version.

@lilymooncake
Copy link
Author

lilymooncake commented Jun 15, 2023

Thanks, Graham, I did but it still happens and only can be solved by the workaround. However, this ticket can be closed.

@GrahamDumpleton
Copy link
Owner

If the code doesn't look like what I linked in the GitHub repo, then something is causing you to be pinned to an older version of wrapt.

If you are adamant that the code does match what is in the repo, then run:

pip freeze

and provide the output so can confirm what version pip thinks you have installed.

Also run the Python command line interpreter and from it do:

import wrapt
print(wrapt.__version_info__)

and see what the wrapt package itself says it is. Provide this output as well.

I would not be surprised if you are using some third party package which has pinned to an old version of wrapt and so when you install things it is being force to the old version.

kmichel-aiven added a commit to Aiven-Open/rohmu that referenced this issue Jul 13, 2023
This should avoid GrahamDumpleton/wrapt#239 on Python 3.11
kmichel-aiven added a commit to Aiven-Open/rohmu that referenced this issue Jul 13, 2023
This should avoid GrahamDumpleton/wrapt#239 on Python 3.11
kmichel-aiven added a commit to Aiven-Open/rohmu that referenced this issue Jul 13, 2023
This should avoid GrahamDumpleton/wrapt#239 on Python 3.11
kmichel-aiven added a commit to Aiven-Open/rohmu that referenced this issue Jul 13, 2023
This should avoid GrahamDumpleton/wrapt#239 on Python 3.11
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