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

pyang cannot run in Python 3.12 (pkg_resources) #911

Open
JennToo opened this issue Jun 20, 2024 · 2 comments
Open

pyang cannot run in Python 3.12 (pkg_resources) #911

JennToo opened this issue Jun 20, 2024 · 2 comments

Comments

@JennToo
Copy link

JennToo commented Jun 20, 2024

Traceback (most recent call last):
  File "/tmp/build/.porg/venvs/3.12-d/bin/pyang", line 5, in <module>
    from pyang.scripts.pyang_tool import run
  File "/tmp/build/.porg/venvs/3.12-d/lib/python3.12/site-packages/pyang/scripts/pyang_tool.py", line 12, in <module>
    from pyang import plugin
  File "/tmp/build/.porg/venvs/3.12-d/lib/python3.12/site-packages/pyang/plugin.py", line 5, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

pkg_resources has been deprecated for a while now and was finally removed in 3.12 it seems.

@991jo
Copy link

991jo commented Aug 14, 2024

I ran into the same problem when my default venv was created with setuptools version 69.
When I upgraded it via pip install --upgrade setuptools to 72.2.0 it worked again.

@cpascual
Copy link

cpascual commented Oct 9, 2024

pkg_resources can be replaced by importlib.resources which is available since python 3.7 (the oldest version supported by pyang)

Note: I ran into this using python 3.11 but installing pyang with uv which does not install setuptools by default:

$ uvx  pyang --version
Traceback (most recent call last):
...
ModuleNotFoundError: No module named 'pkg_resources'

A workaround that works for me is:

$ uvx --with setuptools pyang --version
pyang 2.6.1

IMHO this is a bug in pyang because it uses pkg_resources without declaring setuptools as a dependency.

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

3 participants