-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Python Quickstart sample does not work #122121
Python Quickstart sample does not work #122121
Comments
@userr2232 |
@userr2232 |
Remove the "https://" part and also the "/contentsafety/text:detectGroundedness?api-version=2024-02-15-preview" from the endpoint in "conn = http.client.HTTPSConnection" line and it will work. It's a python thing. |
@sakisrokanas @userr2232 |
@userr2232 #Please-close |
Hi @Naveenommi-MSFT, the solution provided does not work for me. I am getting the error message below. I also updated my Python version to 3.11.9, but that hasn't helped either.
For reference, this is how my code after following the suggestion above:
|
Could please try this below python version which is mentioned in Azure documentation. and also try to Remove the "https://" part and also the "/contentsafety/text:detectGroundedness?api-version=2024-02-15-preview" from the endpoint in "conn = http.client.HTTPSConnection" line and it will work. It's a python thing. If still there issue, I'd recommend working closer with our support team via an Azure support request. |
Hello, I'm using Python 3.9.6 on an Intel Mac. Trying to get started with Groundedness detection, but the sample provided in the docs is giving me an error (I redacted my endpoint from the logs):
Traceback (most recent call last): File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/http/client.py", line 872, in _get_hostport port = int(host[i+1:]) ValueError: invalid literal for int() with base 10: 'detectGroundedness?api-version=2024-02-15-preview' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/userr2232/Documents/misc/VizBot/test.py", line 4, in <module> conn = http.client.HTTPSConnection("<endpoint>/contentsafety/text:detectGroundedness?api-version=2024-02-15-preview") File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/http/client.py", line 1384, in __init__ super(HTTPSConnection, self).__init__(host, port, timeout, File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/http/client.py", line 834, in __init__ (self.host, self.port) = self._get_hostport(host, port) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/http/client.py", line 877, in _get_hostport raise InvalidURL("nonnumeric port: '%s'" % host[i+1:]) http.client.InvalidURL: nonnumeric port: 'detectGroundedness?api-version=2024-02-15-preview'
Then, when I instantiate
HTTPSConnection
withport=80
, I get another error:Traceback (most recent call last): File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/encodings/idna.py", line 167, in encode raise UnicodeError("label too long") UnicodeError: label too long The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/userr2232/Documents/misc/VizBot/test.py", line 21, in <module> conn.request("POST", "/contentsafety/text:detectGroundedness?api-version=2024-02-15-preview", payload, headers) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/http/client.py", line 1257, in request self._send_request(method, url, body, headers, encode_chunked) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/http/client.py", line 1303, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/http/client.py", line 1252, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/http/client.py", line 1012, in _send_output self.send(msg) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/http/client.py", line 952, in send self.connect() File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/http/client.py", line 1419, in connect super().connect() File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/http/client.py", line 923, in connect self.sock = self._create_connection( File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/socket.py", line 822, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/socket.py", line 953, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): UnicodeError: encoding with 'idna' codec failed (UnicodeError: label too long)
It seems to be related to Python having a hard limit of 64 characters for the first part of the url, which doesn't make much sense to me, since my host (endpoint) is only 48 characters (including https and .com)
Is there any work around to this? Thank you
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: