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

podman.from_env() not working #223

Closed
josecastillolema opened this issue Dec 3, 2022 · 17 comments · Fixed by #253
Closed

podman.from_env() not working #223

josecastillolema opened this issue Dec 3, 2022 · 17 comments · Fixed by #253

Comments

@josecastillolema
Copy link

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
@cjw296
Copy link

cjw296 commented Feb 28, 2023

Same...

@bdherouville
Copy link

This works. Be sure to activate podman.socket services :
sudo systemctl enable podman.socket
sudo systemctl start podman.socket

podman_client = podman.PodmanClient(base_url="http+unix:///var/run/podman/podman.sock")

@cjw296
Copy link

cjw296 commented Mar 1, 2023

@bdherouville - it really doesn't. I've had better experience connecting to podman using the docker Python library than this one, which is pretty disappointing.

@jwhonce
Copy link
Member

jwhonce commented Mar 7, 2023

@josecastillolema From the stack trace line ValueError: The scheme 'b''' must be one of ('unix', 'http+unix', 'ssh', 'http+ssh', 'tcp', 'http') it appears neither CONTAINER_HOST or DOCKER_HOST is in your environment.

@josecastillolema
Copy link
Author

@bdherouville I dont think the provided workaround works:

$ sudo systemctl enable podman.socket
Created symlink /etc/systemd/system/sockets.target.wants/podman.socket → /usr/lib/systemd/system/podman.socket.

$ sudo systemctl start podman.socket

$ podman ps
CONTAINER ID  IMAGE       COMMAND     CREATED     STATUS      PORTS       NAMES

$ python3
Python 3.6.8 (default, Jan 19 2022, 23:28:49) 
[GCC 8.5.0 20210514 (Red Hat 8.5.0-7)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 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')

@josecastillolema
Copy link
Author

Hi @jwhonce ,
neither CONTAINER_HOST nor DOCKER_HOST are defined in my environment:

$ env | grep CONTAINER_HOST
$ env | grep DOCKER_HOST

Should they be?
I installed podman via: sudo dnf install -y podman

@bdherouville
Copy link

I don't understand, I looked at the python source and the method is : PodmanClient()

After enabling podman.socket I was able to access podman from python using :

podman.PodmanClient(base_url="http+unix:///var/run/podman/podman.sock")

@josecastillolema
Copy link
Author

@bdherouville

$ python3

>>> import podman

>>> client = podman.PodmanClient(base_url="http+unix:///var/run/podman/podman.sock")

>>> client
<podman.client.PodmanClient object at 0x7f2ed2196438>

>>> client.images.list()
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/podman/api/uds.py", line 43, in connect
    super().connect(netloc)
PermissionError: [Errno 13] Permission denied

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib64/python3.6/http/client.py", line 1273, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1319, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1268, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1044, in _send_output
    self.send(msg)
  File "/usr/lib64/python3.6/http/client.py", line 982, in send
    self.connect()
  File "/usr/local/lib/python3.6/site-packages/podman/api/uds.py", line 88, in connect
    sock.connect()
  File "/usr/local/lib/python3.6/site-packages/podman/api/uds.py", line 45, in connect
    raise APIError(f"Unable to make connection to UDS '{netloc}'") from e
podman.errors.exceptions.APIError: Unable to make connection to UDS '/var/run/podman/podman.sock'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 450, in send
    timeout=timeout
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/lib/python3.6/site-packages/urllib3/util/retry.py", line 368, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3.6/site-packages/urllib3/packages/six.py", line 692, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib64/python3.6/http/client.py", line 1273, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1319, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1268, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1044, in _send_output
    self.send(msg)
  File "/usr/lib64/python3.6/http/client.py", line 982, in send
    self.connect()
  File "/usr/local/lib/python3.6/site-packages/podman/api/uds.py", line 88, in connect
    sock.connect()
  File "/usr/local/lib/python3.6/site-packages/podman/api/uds.py", line 45, in connect
    raise APIError(f"Unable to make connection to UDS '{netloc}'") from e
urllib3.exceptions.ProtocolError: ('Connection aborted.', APIError("Unable to make connection to UDS '/var/run/podman/podman.sock'",))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/podman/api/client.py", line 411, in _request
    **timeout_kw,
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 529, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 645, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 501, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', APIError("Unable to make connection to UDS '/var/run/podman/podman.sock'",))

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/podman/domain/images_manager.py", line 56, in list
    response = self.client.get("/images/json", params=params)
  File "/usr/local/lib/python3.6/site-packages/podman/api/client.py", line 243, in get
    **kwargs,
  File "/usr/local/lib/python3.6/site-packages/podman/api/client.py", line 415, in _request
    raise APIError(uri.geturl(), explanation=f"{method.upper()} operation failed") from e
podman.errors.exceptions.APIError: http://%2Fvar%2Frun%2Fpodman%2Fpodman.sock/v4.3.0/libpod/images/json (GET operation failed)

@bdherouville
Copy link

bdherouville commented Mar 8, 2023

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'>]

@rhatdan
Copy link
Member

rhatdan commented Mar 8, 2023

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

@jwhonce
Copy link
Member

jwhonce commented Mar 8, 2023

Hi @jwhonce , neither CONTAINER_HOST nor DOCKER_HOST are defined in my environment:

$ env | grep CONTAINER_HOST
$ env | grep DOCKER_HOST

Should they be? I installed podman via: sudo dnf install -y podman

Those environment variables are interchangeable and one or the other is required when using .from_env() to determine where the podman service is running.

@rhatdan
Copy link
Member

rhatdan commented Mar 8, 2023

Should podman-py just look for them in the standard location if they are not running?

@josecastillolema
Copy link
Author

@rhatdan the rootless podman service does not work either:

$ systemctl --user start podman.socket
$ python3 
Python 3.6.8 (default, Jan 19 2022, 23:28:49) 
[GCC 8.5.0 20210514 (Red Hat 8.5.0-7)] 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 0x7f6d6a7c1400>
>>> client.images.list()
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/podman/api/uds.py", line 43, in connect
    super().connect(netloc)
PermissionError: [Errno 13] Permission denied

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib64/python3.6/http/client.py", line 1273, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1319, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1268, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1044, in _send_output
    self.send(msg)
  File "/usr/lib64/python3.6/http/client.py", line 982, in send
    self.connect()
  File "/usr/local/lib/python3.6/site-packages/podman/api/uds.py", line 88, in connect
    sock.connect()
  File "/usr/local/lib/python3.6/site-packages/podman/api/uds.py", line 45, in connect
    raise APIError(f"Unable to make connection to UDS '{netloc}'") from e
podman.errors.exceptions.APIError: Unable to make connection to UDS '/var/run/podman/podman.sock'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 450, in send
    timeout=timeout
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/lib/python3.6/site-packages/urllib3/util/retry.py", line 368, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3.6/site-packages/urllib3/packages/six.py", line 692, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib64/python3.6/http/client.py", line 1273, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1319, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1268, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1044, in _send_output
    self.send(msg)
  File "/usr/lib64/python3.6/http/client.py", line 982, in send
    self.connect()
  File "/usr/local/lib/python3.6/site-packages/podman/api/uds.py", line 88, in connect
    sock.connect()
  File "/usr/local/lib/python3.6/site-packages/podman/api/uds.py", line 45, in connect
    raise APIError(f"Unable to make connection to UDS '{netloc}'") from e
urllib3.exceptions.ProtocolError: ('Connection aborted.', APIError("Unable to make connection to UDS '/var/run/podman/podman.sock'",))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/podman/api/client.py", line 411, in _request
    **timeout_kw,
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 529, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 645, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 501, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', APIError("Unable to make connection to UDS '/var/run/podman/podman.sock'",))

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/podman/domain/images_manager.py", line 56, in list
    response = self.client.get("/images/json", params=params)
  File "/usr/local/lib/python3.6/site-packages/podman/api/client.py", line 243, in get
    **kwargs,
  File "/usr/local/lib/python3.6/site-packages/podman/api/client.py", line 415, in _request
    raise APIError(uri.geturl(), explanation=f"{method.upper()} operation failed") from e
podman.errors.exceptions.APIError: http://%2Fvar%2Frun%2Fpodman%2Fpodman.sock/v4.3.0/libpod/images/json (GET operation failed)

@josecastillolema
Copy link
Author

@jwhonce so I guess the question is, who is responsible for defining this variables and why are not defined in my environments?
Is it a user responsibility or should they be handled as part of podman installation?

@rhatdan
Copy link
Member

rhatdan commented Mar 17, 2023

You should not specify the base_url
base_url="http+unix:///var/run/podman/podman.sock

This is the path for the rootful socket. look at the example below. python-podman does the right thing.

$ python
Python 3.11.2 (main, Feb  8 2023, 00:00:00) [GCC 13.0.1 20230208 (Red Hat 13.0.1-0)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import podman
>>> client = podman.PodmanClient()
>>> client.images.list()
[<Image: 'quay.io/libpod/testimage:20221018'>, <Image: 'registry.access.redhat.com/ubi9:latest'>, <Image: 'docker.io/library/golang:1.17'>]

@josecastillolema
Copy link
Author

@rhatdan :

$ python3
Python 3.6.8 (default, Jan 19 2022, 23:28:49) 
[GCC 8.5.0 20210514 (Red Hat 8.5.0-7)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import podman
>>> client = podman.PodmanClient()
>>> client.images.list()
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/podman/api/uds.py", line 43, in connect
    super().connect(netloc)
FileNotFoundError: [Errno 2] No such file or directory

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib64/python3.6/http/client.py", line 1273, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1319, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1268, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1044, in _send_output
    self.send(msg)
  File "/usr/lib64/python3.6/http/client.py", line 982, in send
    self.connect()
  File "/usr/local/lib/python3.6/site-packages/podman/api/uds.py", line 88, in connect
    sock.connect()
  File "/usr/local/lib/python3.6/site-packages/podman/api/uds.py", line 45, in connect
    raise APIError(f"Unable to make connection to UDS '{netloc}'") from e
podman.errors.exceptions.APIError: Unable to make connection to UDS '/run/user/503/podman/podman.sock'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 450, in send
    timeout=timeout
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/lib/python3.6/site-packages/urllib3/util/retry.py", line 368, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3.6/site-packages/urllib3/packages/six.py", line 692, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib64/python3.6/http/client.py", line 1273, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1319, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1268, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1044, in _send_output
    self.send(msg)
  File "/usr/lib64/python3.6/http/client.py", line 982, in send
    self.connect()
  File "/usr/local/lib/python3.6/site-packages/podman/api/uds.py", line 88, in connect
    sock.connect()
  File "/usr/local/lib/python3.6/site-packages/podman/api/uds.py", line 45, in connect
    raise APIError(f"Unable to make connection to UDS '{netloc}'") from e
urllib3.exceptions.ProtocolError: ('Connection aborted.', APIError("Unable to make connection to UDS '/run/user/503/podman/podman.sock'",))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/podman/api/client.py", line 411, in _request
    **timeout_kw,
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 529, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 645, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 501, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', APIError("Unable to make connection to UDS '/run/user/503/podman/podman.sock'",))

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/podman/domain/images_manager.py", line 56, in list
    response = self.client.get("/images/json", params=params)
  File "/usr/local/lib/python3.6/site-packages/podman/api/client.py", line 243, in get
    **kwargs,
  File "/usr/local/lib/python3.6/site-packages/podman/api/client.py", line 415, in _request
    raise APIError(uri.geturl(), explanation=f"{method.upper()} operation failed") from e
podman.errors.exceptions.APIError: http://%2Frun%2Fuser%2F503%2Fpodman%2Fpodman.sock/v4.3.0/libpod/images/json (GET operation failed)

jwhonce added a commit to jwhonce/podman-py that referenced this issue Mar 20, 2023
When using from_env() and having not set one of the necessary env var.

```python
import sys
sys.path.insert(0, './podman')
import podman
podman.from_env()
```

causes:

```ValueError: CONTAINER_HOST or DOCKER_HOST must be set to URL of podman service.```

fixes containers#223

Signed-off-by: Jhon Honce <jhonce@redhat.com>
@rhatdan
Copy link
Member

rhatdan commented Mar 21, 2023

Is your podman.service running? And listening on /run/user/503/podman/podman.sock?

If you do podman --remote version does it also blow up?

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

Successfully merging a pull request may close this issue.

5 participants