InvalidSchema("No connection adapters were found for '%s'" % url)
See original GitHub issueraise InvalidSchema("No connection adapters were found for '%s'" % url)
requests.exceptions.InvalidSchema: <exception str() failed>
Getting the above error when I do:
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36'}
r = requests.get(page_url, headers=headers)
Where page_url is the URL of the webpage I’m requesting. I’ve confirmed the URL is correct and stored in page_url properly; the issue appears to be the fact that I’m grabbing the URL from a file. Replacing page_url with the actual URL removes the error. Is there some issue with using a URL that’s stored in a variable rather than hardcoding it or something?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:13 (6 by maintainers)
Top Results From Across the Web
Python Requests - No connection adapters - Stack Overflow
In my case, I received this error when I refactored a url, ... 742 raise InvalidSchema("No connection adapters were found for {!r}".format(url)) 743...
Read more >Error: InvalidSchema("No connection adapters were found for ...
Solution. Check if the URL provided for the STACKSTATE_BASE_URL environment variable on AWS Lambda function is correct. Be sure that protocol is ...
Read more >How to tackle the "No connection adapters" error? - Reddit
I have an excel document that contains a row of URL's for various pdf files. ... No connection adapters were found for 'html://www.....'....
Read more >258389 – ports-mgmt/distilator: Fails on comms/qtel: requests ...
InvalidSchema : No connection adapters were found for 'make:' ... line 134, in validate_url_pool req = requests.head(url, ...
Read more >E-ES: Kibana install fails - Elasticsearch service is not running
E-ES: Kibana install fails - Elasticsearch service is not running - raise InvalidSchema("No connection adapters were found for '%s'" % url) ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRY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6DPwfDJMQn7WwsPPd/Ye1auNYpHSQcQoC1pAzXFp/CNXivHB8bpqGhbBLHK5wc4ktAtpPiuo5Q4aTc0stz/AObd61pVUacRnhvf2JWEujJa41/ungf0VT/EGGeqyeW3esrG8Qpq8w8VidHmZ2dnNAve2oryW0VxjlTyyrSS3P3heOOw+m4EU4k5xdfPt0/Jdf8AFUnqbfN/wp1FENZfFcKfQKbRWYZj7q6tZTupmszgecH36B4L0xjGXYdUMhEAkzmZ18+3aRq9inMHqY6PEI55b5jQb2Fz0Fe2PV0NfVxyQZ2a2PNNxbtO9exayfd23L5sluP5dzikk4esfLm5vCSF1r3tc3VXlP1Q7327VIR/mN8Qq/Kfqh3vt2rPStui1vwIjsyOREXNMwiIgCIiA0snSBjEF/bsK0MsI3cJTy25maQT2XusCGV8MrJYzZ7DcFVdLlBRTRDjX8uS2kFtx8l0dLKE6ZUyeDSOGsMkfmE+YVryzhPes8s7k5YwnvmeWdynuNXmongXiRXzCfMK15ZwnvWeWdycsYT3zPLO5O41+YhwLxIrRrT5hWvLOE96zyzuTljCe+Z5Z3J3GvzUOBeJFaNYTRrCteWcJ71nlncnLOFd6zyzuTuVXmIcC8SOgYZJ42MBc4uAACrcpzbCCDoJe1fs41hbRdsrbjVGb7FP43ivKD2sjBbAzSAeknWrtVaamaU8uQwkjLREXKMwiIhAREQBERAEREJCIiAIiIAiIgCIiEBERAEREAREQBERAEREAREQBERAEREAREQBERAEREB//9k=
this is image url… I am getting this error “No connection adapters were found for” when I try to send request in python.
i have this issue too. below is the code. import os import json import io import requests import numpy as np import tensorflow as tf from PIL import Image import matplotlib.pyplot as plt import PIL
ASSETS_DIR = r"C:\Users\Sortol\Documents\adesoji-fastapi\assets" TEST_IMAGES_DIR = r"C:\Users\Sortol\Documents\adesoji-fastapi\images"
classes = json.load(open(os.path.join(ASSETS_DIR,‘categories.json’))) classes = {v:k for k,v in classes.items()}
URL = “/v1/models/flower-classification:predict”
def read_img_file(file) -> Image.Image: img = Image.open(io.BytesIO(file)) if img.mode == “RGBA”: img = img.convert(“RGB”) img = img.resize((224,224), Image.ANTIALIAS) img = tf.expand_dims(np.asarray(img)/255, 0) return img
def load_img(img_path, show:bool=False):
img_path = random.choice(glob.glob(f"{DATASET_DIR}/test/{cls}/*.jpg"))
img = PIL.Image.open(img_path) img = img.resize((224,224), PIL.Image.ANTIALIAS) if show: plt.imshow(img) plt.title(‘cls’) img = tf.expand_dims(np.asarray(img)/255, 0) return img
def predict(img): headers = { “content-type” : “application/json” } data = json.dumps({ “signature_name”: “serving_default”, “instances”: img.numpy().tolist() }) response = requests.post(URL, data=data, headers=headers) response_data = json.loads(response.text)[‘predictions’][0] confidence = np.max(response_data) predicted_class = classes[np.argmax(response_data)] return response_data,confidence,predicted_class
now i get this error below
C:\Users\Sortol\Documents\adesoji-fastapi\app>uvicorn main:app 2021-03-01 23:18:10.330558: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll INFO: Started server process [6912] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) INFO: 127.0.0.1:54121 - “GET / HTTP/1.1” 404 Not Found INFO: 127.0.0.1:54129 - “GET /docs HTTP/1.1” 200 OK INFO: 127.0.0.1:54129 - “GET /openapi.json HTTP/1.1” 200 OK 2021-03-01 23:18:39.587847: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set 2021-03-01 23:18:39.596337: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library nvcuda.dll 2021-03-01 23:18:39.686352: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties: pciBusID: 0000:03:00.0 name: GeForce 840M computeCapability: 5.0 coreClock: 1.124GHz coreCount: 3 deviceMemorySize: 2.00GiB deviceMemoryBandwidth: 13.41GiB/s 2021-03-01 23:18:39.687791: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll 2021-03-01 23:18:39.782907: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublas64_11.dll 2021-03-01 23:18:39.783942: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublasLt64_11.dll 2021-03-01 23:18:39.832809: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cufft64_10.dll 2021-03-01 23:18:39.844951: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library curand64_10.dll 2021-03-01 23:18:39.939685: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusolver64_10.dll 2021-03-01 23:18:39.961540: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusparse64_11.dll 2021-03-01 23:18:39.965590: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudnn64_8.dll 2021-03-01 23:18:39.966611: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0 2021-03-01 23:18:39.981739: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2021-03-01 23:18:39.985255: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties: pciBusID: 0000:03:00.0 name: GeForce 840M computeCapability: 5.0 coreClock: 1.124GHz coreCount: 3 deviceMemorySize: 2.00GiB deviceMemoryBandwidth: 13.41GiB/s 2021-03-01 23:18:39.987565: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll 2021-03-01 23:18:39.988770: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublas64_11.dll 2021-03-01 23:18:39.989115: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublasLt64_11.dll 2021-03-01 23:18:39.989445: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cufft64_10.dll 2021-03-01 23:18:39.989775: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library curand64_10.dll 2021-03-01 23:18:39.991063: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusolver64_10.dll 2021-03-01 23:18:39.991441: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusparse64_11.dll 2021-03-01 23:18:39.991842: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudnn64_8.dll 2021-03-01 23:18:39.993129: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0 2021-03-01 23:18:43.086253: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1261] Device interconnect StreamExecutor with strength 1 edge matrix: 2021-03-01 23:18:43.088620: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1267] 0 2021-03-01 23:18:43.089128: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1280] 0: N 2021-03-01 23:18:43.107867: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1406] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 1369 MB memory) -> physical GPU (device: 0, name: GeForce 840M, pci bus id: 0000:03:00.0, compute capability: 5.0) 2021-03-01 23:18:43.156687: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set tf.Tensor( [[[[0.64705882 0.65490196 0.48627451] [0.58823529 0.60392157 0.46666667] [0.54117647 0.56078431 0.42352941] … [0.35686275 0.52941176 0.32941176] [0.20392157 0.34509804 0.23529412] [0.13333333 0.25882353 0.14117647]]
[[0.6627451 0.69411765 0.51372549] [0.58431373 0.60784314 0.4627451 ] [0.50588235 0.50980392 0.4 ] … [0.39607843 0.55294118 0.36470588] [0.15294118 0.29411765 0.18431373] [0.05098039 0.18823529 0.06666667]]
[[0.61960784 0.64313725 0.50196078] [0.63921569 0.62745098 0.52156863] [0.57254902 0.51764706 0.47843137] … [0.38039216 0.52156863 0.36862745] [0.16862745 0.30980392 0.21568627] [0.0745098 0.21960784 0.09411765]]
…
[[0.32941176 0.48627451 0.33333333] [0.32941176 0.48627451 0.3254902 ] [0.31764706 0.50196078 0.32156863] … [0.57254902 0.68235294 0.66666667] [0.23529412 0.34509804 0.36078431] [0.20784314 0.3254902 0.29411765]]
[[0.36078431 0.48235294 0.3372549 ] [0.35686275 0.49019608 0.32941176] [0.34117647 0.52156863 0.3372549 ] … [0.53333333 0.67058824 0.63137255] [0.22745098 0.36078431 0.37254902] [0.27843137 0.40392157 0.37647059]]
[[0.34509804 0.4745098 0.32941176] [0.34117647 0.49019608 0.32156863] [0.33333333 0.52156863 0.3254902 ] … [0.51764706 0.67843137 0.61568627] [0.25098039 0.40392157 0.40784314] [0.22352941 0.37647059 0.33333333]]]], shape=(1, 224, 224, 3), dtype=float64) INFO: 127.0.0.1:54141 - “POST /predict HTTP/1.1” 500 Internal Server Error ERROR: Exception in ASGI application Traceback (most recent call last): File “c:\users\sortol\anaconda3\lib\site-packages\uvicorn\protocols\http\h11_impl.py”, line 396, in run_asgi result = await app(self.scope, self.receive, self.send) File “c:\users\sortol\anaconda3\lib\site-packages\uvicorn\middleware\proxy_headers.py”, line 45, in call return await self.app(scope, receive, send) File “c:\users\sortol\anaconda3\lib\site-packages\fastapi\applications.py”, line 199, in call await super().call(scope, receive, send) File “c:\users\sortol\anaconda3\lib\site-packages\starlette\applications.py”, line 111, in call await self.middleware_stack(scope, receive, send) File “c:\users\sortol\anaconda3\lib\site-packages\starlette\middleware\errors.py”, line 181, in call raise exc from None File “c:\users\sortol\anaconda3\lib\site-packages\starlette\middleware\errors.py”, line 159, in call await self.app(scope, receive, _send) File “c:\users\sortol\anaconda3\lib\site-packages\starlette\exceptions.py”, line 82, in call raise exc from None File “c:\users\sortol\anaconda3\lib\site-packages\starlette\exceptions.py”, line 71, in call await self.app(scope, receive, sender) File “c:\users\sortol\anaconda3\lib\site-packages\starlette\routing.py”, line 566, in call await route.handle(scope, receive, send) File “c:\users\sortol\anaconda3\lib\site-packages\starlette\routing.py”, line 227, in handle await self.app(scope, receive, send) File “c:\users\sortol\anaconda3\lib\site-packages\starlette\routing.py”, line 41, in app response = await func(request) File “c:\users\sortol\anaconda3\lib\site-packages\fastapi\routing.py”, line 201, in app raw_response = await run_endpoint_function( File “c:\users\sortol\anaconda3\lib\site-packages\fastapi\routing.py”, line 148, in run_endpoint_function return await dependant.call(**values) File “.\main.py”, line 21, in predict_image predictions = predict(flower_img) File “.\helpers.py”, line 46, in predict response = requests.post(URL, data=data, headers=headers) File “c:\users\sortol\anaconda3\lib\site-packages\requests\api.py”, line 119, in post return request(‘post’, url, data=data, json=json, **kwargs) File “c:\users\sortol\anaconda3\lib\site-packages\requests\api.py”, line 61, in request return session.request(method=method, url=url, **kwargs) File “c:\users\sortol\anaconda3\lib\site-packages\requests\sessions.py”, line 530, in request resp = self.send(prep, **send_kwargs) File “c:\users\sortol\anaconda3\lib\site-packages\requests\sessions.py”, line 637, in send adapter = self.get_adapter(url=request.url) File “c:\users\sortol\anaconda3\lib\site-packages\requests\sessions.py”, line 730, in get_adapter raise InvalidSchema(“No connection adapters were found for {!r}”.format(url)) requests.exceptions.InvalidSchema: No connection adapters were found for ‘/v1/models/flower-classification:predict’