votes up 4

No connection adapters were found for (!r)

Package:
Exception Class:
InvalidSchema

Raise code

""" 
        """
        for (prefix, adapter) in self.adapters.items():

            if url.lower().startswith(prefix.lower()):
                return adapter

        # Nothing matches :-/
        raise InvalidSchema("No connection adapters were found for {!r}".format(url))

    def close(self):
        """Closes all adapters and as such the session"""
        for v in self.adapters.values():
            v.close()

    def mount(self, prefix, adapter):

Comment explaining raise

Nothing matches :-/

😲 Agile task management is now easier than calling a taxi. #Tracklify
🙏 Scream for help to Ukraine
Today, 2nd July 2022, Russia continues bombing and firing Ukraine. Don't trust Russia, they are bombing us and brazenly lying in same time they are not doing this 😠, civilians and children are dying too! We are screaming and asking exactly you to help us, we want to survive, our families, children, older ones.
Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.

Ways to fix

votes up 1 votes down

Dec 30, 2021 zaytcev1976 answer
votes up 0 votes down

Steps to reproduce:

Step 1: Create a new directory using the command

$ mkdir test-requests

Step 2: Navigate to that directory using the command

$ cd test-requests

Step 3: Run the following command

$ pipenv shell

Step 4: Install the dependencies in a virtual environment using the command

$ pipenv install requests

Step 5: Run the following code to reproduce the exception

import requests

requests.get("'https://google.com'") # notice the incorrect use of quotes

The above code generates the following exception:

---------------------------------------------------------------------------
InvalidSchema                             Traceback (most recent call last)
<ipython-input-53-71a1cbef6f17> in <module>()
      1 import requests
      2 
----> 3 requests.get("'https://google.com'")

/usr/local/lib/python3.7/dist-packages/requests/sessions.py in get_adapter(self, url)
    726 
    727         # Nothing matches :-/
--> 728         raise InvalidSchema("No connection adapters were found for {!r}".format(url))
    729 
    730     def close(self):

InvalidSchema: No connection adapters were found for "'https://google.com'"


Fixed version of code:

import requests

requests.get("https://google.com")
Jun 18, 2021 umangtaneja98 answer

Add a possible fix

Please authorize to post fix