containers / podman-py

Python bindings for Podman's RESTful API
Apache License 2.0
252 stars 94 forks source link

example usage doesn't work on EL9 and clones #370

Closed mailinglists35 closed 4 months ago

mailinglists35 commented 9 months ago
[suport@podman2 ~]$ python3 podman.py
Traceback (most recent call last):
  File "/home/suport/podman.py", line 3, in <module>
    from podman import PodmanClient
  File "/home/suport/podman.py", line 3, in <module>
    from podman import PodmanClient
ImportError: cannot import name 'PodmanClient' from partially initialized module 'podman' (most likely due to a circular import) (/home/suport/podman.py)

requirements:

[suport@podman2 ~]$ pip install -U sphinx
Defaulting to user installation because normal site-packages is not writeable
Collecting sphinx
  Downloading sphinx-7.2.6-py3-none-any.whl (3.2 MB)
     |████████████████████████████████| 3.2 MB 2.1 MB/s
Collecting Pygments>=2.14
  Downloading pygments-2.17.2-py3-none-any.whl (1.2 MB)
     |████████████████████████████████| 1.2 MB 41.4 MB/s
Collecting sphinxcontrib-jsmath
  Downloading sphinxcontrib_jsmath-1.0.1-py2.py3-none-any.whl (5.1 kB)
Collecting alabaster<0.8,>=0.7
  Downloading alabaster-0.7.16-py3-none-any.whl (13 kB)
Collecting imagesize>=1.3
  Downloading imagesize-1.4.1-py2.py3-none-any.whl (8.8 kB)
Collecting sphinxcontrib-applehelp
  Downloading sphinxcontrib_applehelp-1.0.8-py3-none-any.whl (120 kB)
     |████████████████████████████████| 120 kB 39.2 MB/s
Collecting sphinxcontrib-qthelp
  Downloading sphinxcontrib_qthelp-1.0.7-py3-none-any.whl (89 kB)
     |████████████████████████████████| 89 kB 13.5 MB/s
Collecting sphinxcontrib-serializinghtml>=1.1.9
  Downloading sphinxcontrib_serializinghtml-1.1.10-py3-none-any.whl (92 kB)
     |████████████████████████████████| 92 kB 2.1 MB/s
Collecting docutils<0.21,>=0.18.1
  Downloading docutils-0.20.1-py3-none-any.whl (572 kB)
     |████████████████████████████████| 572 kB 116.5 MB/s
Collecting Jinja2>=3.0
  Downloading Jinja2-3.1.3-py3-none-any.whl (133 kB)
     |████████████████████████████████| 133 kB 51.8 MB/s
Collecting sphinxcontrib-devhelp
  Downloading sphinxcontrib_devhelp-1.0.6-py3-none-any.whl (83 kB)
     |████████████████████████████████| 83 kB 3.9 MB/s
Collecting importlib-metadata>=4.8
  Downloading importlib_metadata-7.0.1-py3-none-any.whl (23 kB)
Collecting packaging>=21.0
  Downloading packaging-23.2-py3-none-any.whl (53 kB)
     |████████████████████████████████| 53 kB 5.6 MB/s
Collecting babel>=2.9
  Downloading Babel-2.14.0-py3-none-any.whl (11.0 MB)
     |████████████████████████████████| 11.0 MB 148 kB/s
Collecting sphinxcontrib-htmlhelp>=2.0.0
  Downloading sphinxcontrib_htmlhelp-2.0.5-py3-none-any.whl (99 kB)
     |████████████████████████████████| 99 kB 14.0 MB/s
Collecting snowballstemmer>=2.0
  Downloading snowballstemmer-2.2.0-py2.py3-none-any.whl (93 kB)
     |████████████████████████████████| 93 kB 2.5 MB/s
Requirement already satisfied: requests>=2.25.0 in /usr/lib/python3.9/site-packages (from sphinx) (2.25.1)
Collecting zipp>=0.5
  Downloading zipp-3.17.0-py3-none-any.whl (7.4 kB)
Collecting MarkupSafe>=2.0
  Downloading MarkupSafe-2.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/lib/python3.9/site-packages (from requests>=2.25.0->sphinx) (1.26.5)
Requirement already satisfied: idna<3,>=2.5 in /usr/lib/python3.9/site-packages (from requests>=2.25.0->sphinx) (2.10)
Requirement already satisfied: chardet<5,>=3.0.2 in /usr/lib/python3.9/site-packages (from requests>=2.25.0->sphinx) (4.0.0)
Installing collected packages: zipp, MarkupSafe, sphinxcontrib-serializinghtml, sphinxcontrib-qthelp, sphinxcontrib-jsmath, sphinxcontrib-htmlhelp, sphinxcontrib-devhelp, sphinxcontrib-applehelp, snowballstemmer, Pygments, packaging, Jinja2, importlib-metadata, imagesize, docutils, babel, alabaster, sphinx
  WARNING: Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
  distutils: /home/suport/.local/lib/python3.9/site-packages
  sysconfig: /home/suport/.local/lib64/python3.9/site-packages
  WARNING: Additional context:
  user = True
  home = None
  root = None
  prefix = None
Successfully installed Jinja2-3.1.3 MarkupSafe-2.1.4 Pygments-2.17.2 alabaster-0.7.16 babel-2.14.0 docutils-0.20.1 imagesize-1.4.1 importlib-metadata-7.0.1 packaging-23.2 snowballstemmer-2.2.0 sphinx-7.2.6 sphinxcontrib-applehelp-1.0.8 sphinxcontrib-devhelp-1.0.6 sphinxcontrib-htmlhelp-2.0.5 sphinxcontrib-jsmath-1.0.1 sphinxcontrib-qthelp-1.0.7 sphinxcontrib-serializinghtml-1.1.10 zipp-3.17.0

[suport@podman2 ~]$ rpm -aq|grep py|grep tom
python3-toml-0.10.2-6.0.1.el9.noarch
python3-tomli-2.0.1-5.el9.noarch
[suport@podman2 ~]$ rpm -aq|grep py|grep url
python3-urllib3-1.26.5-3.0.1.el9.noarch
[suport@podman2 ~]$ rpm -aq|grep py|grep wheel
python3-setuptools-wheel-53.0.0-12.el9.noarch
python3-pip-wheel-21.2.3-7.el9.noarch
[suport@podman2 ~]$ rpm -aq|grep pyx
python3-pyxdg-0.27-3.el9.noarch
[suport@podman2 ~]$ rpm -aq|grep py|grep req
python3-requests-2.25.1-7.el9_2.noarch
[suport@podman2 ~]$ rpm -aq|grep py|grep setup
python3-setuptools-wheel-53.0.0-12.el9.noarch
python3-rhn-setup-2.8.16-13.0.8.el9_0.x86_64
python3-setuptools-53.0.0-12.el9.noarch
AdSegura commented 6 months ago

Same error here, my script was named podman.py, just rename it to something else and it will work

inknos commented 4 months ago

closing, I reproduced it and having the script named anything else than podman works :)

mailinglists35 commented 4 months ago

so you did not actually make any fix, you just closed the issue? that's not fixing, that is just a workaround.

inknos commented 3 months ago

As far as I understood, the script does not work if it's named podman.py. This is a totally legit python modules behavior. If you name the file the same as a module, it can make the python import calls ambiguous. I would suggest changing your file name unless you have a very specific reason to keep it called podman.py.

I can suggest more workarounds for the issue, but that's really a matter of python, not of podman-py. The issue is closed simply because it is not a bug.

You are welcome to reopen the issue with more details of your use case.

mailinglists35 commented 3 months ago

thanks for the explanation.

as a non-coder just a copypasta monkey, it literally makes no sense to me for something not work if called a particular name.

I mean this is 2024, not 1980's when msdos would not allow files named CON or some others