podman-py: podman.from_env() not working

Everytime I try podman.from_env() I get this error:

>>> import podman
>>> podman.from_env()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/podman/client.py", line 131, in from_env
    max_pool_size=max_pool_size,
  File "/usr/local/lib/python3.6/site-packages/podman/client.py", line 76, in __init__
    self.api = APIClient(**api_kwargs)
  File "/usr/local/lib/python3.6/site-packages/podman/api/client.py", line 116, in __init__
    self.base_url = self._normalize_url(base_url)
  File "/usr/local/lib/python3.6/site-packages/podman/api/client.py", line 159, in _normalize_url
    f"The scheme '{uri.scheme}' must be one of {APIClient.supported_schemes}"
ValueError: The scheme 'b''' must be one of ('unix', 'http+unix', 'ssh', 'http+ssh', 'tcp', 'http')

Have tried CentOS 8 stream with a native podman setup and MacOS with podman machine.

Are they any pre-reqs to be able to use podman.from_env() ?

Thanks

CentOS Stream release 8:

$ podman version
Client:       Podman Engine
Version:      4.2.0
API Version:  4.2.0
Go Version:   go1.18.4
Built:        Wed Sep 21 13:15:04 2022
OS/Arch:      linux/amd64

MacOS:

% podman version
Client:       Podman Engine
Version:      4.3.0
API Version:  4.3.0
Go Version:   go1.19
Git Commit:   ad42af94903ce4f3c3cd0693e4e17e4286bf094b
Built:        Wed Oct 19 15:33:33 2022
OS/Arch:      darwin/amd64

Server:       Podman Engine
Version:      4.3.1
API Version:  4.3.1
Go Version:   go1.19.2
Built:        Fri Nov 11 16:01:27 2022
OS/Arch:      linux/amd64

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 17 (6 by maintainers)

Commits related to this issue

Most upvoted comments

you should NOT be communication with the /var/run/podman/podman.sock from non root users. If you want to run rootless containers then you should start a rootless podman service

systemctsl --user start podman.socket

Hi @josecastillolema

I just tested on my machine. It is probably an issue with the right on /var/run/podman/podman.sock

I need to test to restart the podman.socket service and run it as root:wheel

bash-4.4# python3 
Python 3.6.8 (default, Jan 11 2023, 08:43:50) 
[GCC 8.5.0 20210514 (Red Hat 8.5.0-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import podman
>>> client = podman.PodmanClient(base_url="http+unix:///var/run/podman/podman.sock")
>>> client
<podman.client.PodmanClient object at 0x7f3f06b46e10>
>>> client.images.list()
[<Image: 'quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:847027714e33fd897a4212811c881ec8c736e068c9a81b968346c3e5c90b3c8b'>, <Image: 'quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:9f0cdc00b1b1a3c17411e50653253b9f6bb5329ea4fb82ad983790a6dbf2d9ad'>, <Image: 'quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:bc620e8c2cb2e1321215ef801a860b80a266c9269e2d765a057fd80e7e76332d'>, <Image: 'quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:14794ac4b4b5e1bb2728d253b939578a03730cf26ba5cf795c8e2d26b9737dd6'>, <Image: 'registry.access.redhat.com/ubi8/openssl@sha256:9e743d947be073808f7f1750a791a3dbd81e694e37161e8c6c6057c2c342d671'>, <Image: 'quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:dfdf833d03dac36b747951107a25ab6424eb387bb140f344d4be8d8c7f4e895f'>, <Image: 'quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:fa1ff52055ededc0386ee6b334ffe0cd9252f5878fcccf1396aee30adf6de046'>, <Image: 'registry.redhat.io/lvms4/topolvm-rhel8@sha256:10bffded5317da9de6c45ba74f0bb10e0a08ddb2bfef23b11ac61287a37f10a1'>, <Image: 'quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:c28f27a3a10df13e5e8c074e8734683a6603ebaccd9d67e2095070fb6859b1d6'>, <Image: 'quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:6bd9d4dc813a01257767fb3b16395e8aee044feec410ed8e93ee1e82daf5a744'>, <Image: 'quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:12be6984e3a56cbc5b2a5272a872a40b242cce8a0f167993107c6de6bf776c53'>, <Image: 'quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:836d284f0c24a1d400cebc0f25e8172c28e7476879bfffe1071fb9ceb169c9ce'>, <Image: 'quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:f18e0cf76a2ac840c9f66f89f1b47aced70650021e7931199659aef9cbca31e0'>, <Image: 'registry.k8s.io/prometheus-adapter/prometheus-adapter:v0.10.0'>, <Image: 'k8s.gcr.io/metrics-server/metrics-server:v0.6.2'>, <Image: 'quay.io/prometheus-operator/prometheus-operator:v0.63.0'>, <Image: 'docker.io/fabxc/instrumented_app:latest'>, <Image: 'quay.io/prometheus-operator/prometheus-config-reloader:v0.63.0'>, <Image: 'quay.io/prometheus/prometheus:v2.42.0'>, <Image: 'registry.k8s.io/debian-base:v2.0.0'>, <Image: 'docker.io/grafana/grafana:latest'>]