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

pylxd.exceptions.ClientConnectionFailed: Not supported URL scheme http+unix #581

Closed
kimfaint opened this issue May 27, 2024 · 6 comments
Closed

Comments

@kimfaint
Copy link

kimfaint commented May 27, 2024

Installed pylxd:

kim@TAP0001367:~/pylxd$ python3 -m venv venv
kim@TAP0001367:~/pylxd$ . venv/bin/activate
(venv) kim@TAP0001367:~/pylxd$ pip install pylxd
Collecting pylxd
  Downloading pylxd-2.3.3-py3-none-any.whl (94 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 94.7/94.7 kB 2.0 MB/s eta 0:00:00
Collecting cryptography>=3.2
  Downloading cryptography-42.0.7-cp39-abi3-manylinux_2_28_x86_64.whl (3.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.8/3.8 MB 8.0 MB/s eta 0:00:00
Collecting python-dateutil>=2.4.2
  Downloading python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 229.9/229.9 kB 7.3 MB/s eta 0:00:00
Collecting requests>=2.20.0
  Downloading requests-2.32.2-py3-none-any.whl (63 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 63.9/63.9 kB 8.4 MB/s eta 0:00:00
Collecting requests-toolbelt>=0.8.0
  Downloading requests_toolbelt-1.0.0-py2.py3-none-any.whl (54 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 54.5/54.5 kB 3.9 MB/s eta 0:00:00
Collecting requests-unixsocket>=0.1.5
  Downloading requests_unixsocket-0.3.0-py2.py3-none-any.whl (11 kB)
Collecting urllib3<2
  Downloading urllib3-1.26.18-py2.py3-none-any.whl (143 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 143.8/143.8 kB 6.6 MB/s eta 0:00:00
Collecting ws4py!=0.3.5,>=0.3.4
  Downloading ws4py-0.5.1.tar.gz (51 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 51.4/51.4 kB 7.7 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Collecting cffi>=1.12
  Downloading cffi-1.16.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (464 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 464.8/464.8 kB 9.4 MB/s eta 0:00:00
Collecting six>=1.5
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting charset-normalizer<4,>=2
  Downloading charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (140 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 140.3/140.3 kB 5.4 MB/s eta 0:00:00
Collecting idna<4,>=2.5
  Downloading idna-3.7-py3-none-any.whl (66 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 66.8/66.8 kB 7.2 MB/s eta 0:00:00
Collecting certifi>=2017.4.17
  Downloading certifi-2024.2.2-py3-none-any.whl (163 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 163.8/163.8 kB 9.8 MB/s eta 0:00:00
Collecting pycparser
  Downloading pycparser-2.22-py3-none-any.whl (117 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 117.6/117.6 kB 9.5 MB/s eta 0:00:00
Installing collected packages: ws4py, urllib3, six, pycparser, idna, charset-normalizer, certifi, requests, python-dateutil, cffi, requests-unixsocket, requests-toolbelt, cryptography, pylxd
  DEPRECATION: ws4py is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
  Running setup.py install for ws4py ... done
Successfully installed certifi-2024.2.2 cffi-1.16.0 charset-normalizer-3.3.2 cryptography-42.0.7 idna-3.7 pycparser-2.22 pylxd-2.3.3 python-dateutil-2.9.0.post0 requests-2.32.2 requests-toolbelt-1.0.0 requests-unixsocket-0.3.0 six-1.16.0 urllib3-1.26.18 ws4py-0.5.1

Attept to create a Client:

(venv) kim@TAP0001367:~/pylxd$ python
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pylxd import Client
>>> client = Client()
Traceback (most recent call last):
  File "/home/kim/pylxd/venv/lib/python3.11/site-packages/requests/adapters.py", line 555, in send
    conn = self.get_connection_with_tls_context(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kim/pylxd/venv/lib/python3.11/site-packages/requests/adapters.py", line 411, in get_connection_with_tls_context
    conn = self.poolmanager.connection_from_host(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kim/pylxd/venv/lib/python3.11/site-packages/urllib3/poolmanager.py", line 246, in connection_from_host
    return self.connection_from_context(request_context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kim/pylxd/venv/lib/python3.11/site-packages/urllib3/poolmanager.py", line 258, in connection_from_context
    raise URLSchemeUnknown(scheme)
urllib3.exceptions.URLSchemeUnknown: Not supported URL scheme http+unix

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/kim/pylxd/venv/lib/python3.11/site-packages/pylxd/client.py", line 410, in __init__
    response = self.api.get()
               ^^^^^^^^^^^^^^
  File "/home/kim/pylxd/venv/lib/python3.11/site-packages/pylxd/client.py", line 206, in get
    response = self.session.get(self._api_endpoint, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kim/pylxd/venv/lib/python3.11/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kim/pylxd/venv/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kim/pylxd/venv/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kim/pylxd/venv/lib/python3.11/site-packages/requests/adapters.py", line 559, in send
    raise InvalidURL(e, request=request)
requests.exceptions.InvalidURL: Not supported URL scheme http+unix

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kim/pylxd/venv/lib/python3.11/site-packages/pylxd/client.py", line 419, in __init__
    raise exceptions.ClientConnectionFailed(str(e))
pylxd.exceptions.ClientConnectionFailed: Not supported URL scheme http+unix

I found a similar issue here Azure/azure-iot-sdk-python#1182

which links to here psf/requests#6707 and here msabramo/requests-unixsocket#73

And the suggested workaround to downgrade requests to 2.31.0 seems to work:

(venv) kim@TAP0001367:~/pylxd$ pip install requests==2.31.0
Collecting requests==2.31.0
  Using cached requests-2.31.0-py3-none-any.whl (62 kB)
Requirement already satisfied: charset-normalizer<4,>=2 in ./venv/lib/python3.11/site-packages (from requests==2.31.0) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in ./venv/lib/python3.11/site-packages (from requests==2.31.0) (3.7)
Requirement already satisfied: urllib3<3,>=1.21.1 in ./venv/lib/python3.11/site-packages (from requests==2.31.0) (1.26.18)
Requirement already satisfied: certifi>=2017.4.17 in ./venv/lib/python3.11/site-packages (from requests==2.31.0) (2024.2.2)
Installing collected packages: requests
  Attempting uninstall: requests
    Found existing installation: requests 2.32.2
    Uninstalling requests-2.32.2:
      Successfully uninstalled requests-2.32.2
Successfully installed requests-2.31.0
(venv) kim@TAP0001367:~/pylxd$ python
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pylxd import Client
>>> client = Client()
>>>
@simondeziel
Copy link
Member

This is a dup of #579 (fixed by #580). I'll cut a new pylxd release and upload it to pypi soon.

@kimfaint
Copy link
Author

Thanks @simondeziel and apologies, I should have looked at Closed issues.

@simondeziel
Copy link
Member

@kimfaint, no problem at all!

@yanksyoon
Copy link
Contributor

@simondeziel Hello! May I know your schedule for releasing the fix to pypi please if possible? This would unblock canonical/github-runner-image-builder#4 for me :D

@simondeziel
Copy link
Member

@yanksyoon hopefully today (#582)

@simondeziel
Copy link
Member

Done: https://pypi.org/project/pylxd/2.3.4/

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