As a personal project, I'm trying to set up Google Home on a Raspberry Pi. Fresh install of the most recent 64 bit Raspberry Pi OS, following the instructions at (stuck on step 7).
When I run this command (replacing the JSON placeholder):
(env) google-oauthlib-tool --client-secrets "JSON_FILE_PATH" --scope --save --headless
I get this error (full traceback below):
ImportError: The requests library is not installed from please install the requests package to use the requests transport.
I run "pip install requests --break-system-packages" (the switches are my attempt to overcome another error about an "externally-managed-environment"), but it tells me that all the requirements are already met. This is true whether or not I'm in the (env) environment.
Full Traceback:
Traceback (most recent call last):
File "/home/xxx/env/lib/python3.11/site-packages/google/auth/transport/requests.py", line 26, in <module>
import xxx
File "/home/xxx/env/lib/python3.11/site-packages/requests/__init__.py", line 43, in <module>
import urllib3
File "/home/xxx/env/lib/python3.11/site-packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/home/xxx/env/lib/python3.11/site-packages/urllib3/connectionpool.py", line 29, in <module>
from .connection import (
File "/home/xxx/env/lib/python3.11/site-packages/urllib3/connection.py", line 39, in <module>
from .util.ssl_ import (
File "/home/xxx/env/lib/python3.11/site-packages/urllib3/util/__init__.py", line 3, in <module>
from .connection import is_connection_dropped
File "/home/xxx/env/lib/python3.11/site-packages/urllib3/util/connection.py", line 3, in <module>
from .wait import wait_for_read
File "/home/xxx/env/lib/python3.11/site-packages/urllib3/util/wait.py", line 1, in <module>
from .selectors import (
File "/home/xxx/env/lib/python3.11/site-packages/urllib3/util/selectors.py", line 14, in <module>
from collections import namedtuple, Mapping
ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.11/collections/__init__.py)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/xxx/env/bin/google-oauthlib-tool", line 5, in <module>
from google_auth_oauthlib.tool.__main__ import main
File "/home/xxx/env/lib/python3.11/site-packages/google_auth_oauthlib/__init__.py", line 21, in <module>
from .interactive import get_user_credentials
File "/home/xxx/env/lib/python3.11/site-packages/google_auth_oauthlib/interactive.py", line 27, in <module>
import google_auth_oauthlib.flow
File "/home/xxx/env/lib/python3.11/site-packages/google_auth_oauthlib/flow.py", line 65, in <module>
import google.auth.transport.requests
File "/home/xxx/env/lib/python3.11/site-packages/google/auth/transport/requests.py", line 28, in <module>
raise ImportError(
ImportError: The requests library is not installed from please install the requests package to use the requests transport.
Tried to run:
(env) google-oauthlib-tool --client-secrets "JSON_FILE_PATH" --scope --save --headless
Expected to see:
Please go to this URL: https://...
Enter the authorization code:
As a personal project, I'm trying to set up Google Home on a Raspberry Pi. Fresh install of the most recent 64 bit Raspberry Pi OS, following the instructions at https://www.instructables.com/Pi-Home-a-Raspberry-Powered-Virtual-Assistant (stuck on step 7).
When I run this command (replacing the JSON placeholder):
(env) google-oauthlib-tool --client-secrets "JSON_FILE_PATH" --scope https://www.googleapis.com/auth/assistant-sdk-prototype --save --headless
I get this error (full traceback below):
ImportError: The requests library is not installed from please install the requests package to use the requests transport.
I run "pip install requests --break-system-packages" (the switches are my attempt to overcome another error about an "externally-managed-environment"), but it tells me that all the requirements are already met. This is true whether or not I'm in the (env) environment.
Full Traceback:
Traceback (most recent call last):
File "/home/xxx/env/lib/python3.11/site-packages/google/auth/transport/requests.py", line 26, in <module>
import xxx
File "/home/xxx/env/lib/python3.11/site-packages/requests/__init__.py", line 43, in <module>
import urllib3
File "/home/xxx/env/lib/python3.11/site-packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/home/xxx/env/lib/python3.11/site-packages/urllib3/connectionpool.py", line 29, in <module>
from .connection import (
File "/home/xxx/env/lib/python3.11/site-packages/urllib3/connection.py", line 39, in <module>
from .util.ssl_ import (
File "/home/xxx/env/lib/python3.11/site-packages/urllib3/util/__init__.py", line 3, in <module>
from .connection import is_connection_dropped
File "/home/xxx/env/lib/python3.11/site-packages/urllib3/util/connection.py", line 3, in <module>
from .wait import wait_for_read
File "/home/xxx/env/lib/python3.11/site-packages/urllib3/util/wait.py", line 1, in <module>
from .selectors import (
File "/home/xxx/env/lib/python3.11/site-packages/urllib3/util/selectors.py", line 14, in <module>
from collections import namedtuple, Mapping
ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.11/collections/__init__.py)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/xxx/env/bin/google-oauthlib-tool", line 5, in <module>
from google_auth_oauthlib.tool.__main__ import main
File "/home/xxx/env/lib/python3.11/site-packages/google_auth_oauthlib/__init__.py", line 21, in <module>
from .interactive import get_user_credentials
File "/home/xxx/env/lib/python3.11/site-packages/google_auth_oauthlib/interactive.py", line 27, in <module>
import google_auth_oauthlib.flow
File "/home/xxx/env/lib/python3.11/site-packages/google_auth_oauthlib/flow.py", line 65, in <module>
import google.auth.transport.requests
File "/home/xxx/env/lib/python3.11/site-packages/google/auth/transport/requests.py", line 28, in <module>
raise ImportError(
ImportError: The requests library is not installed from please install the requests package to use the requests transport.
Tried to run:
(env) google-oauthlib-tool --client-secrets "JSON_FILE_PATH" --scope https://www.googleapis.com/auth/assistant-sdk-prototype --save --headless
Expected to see:
Please go to this URL: https://...
Enter the authorization code:
Share
Improve this question
edited Feb 8 at 9:33
dave_thompson_085
38.8k6 gold badges56 silver badges80 bronze badges
asked Feb 8 at 3:30
Chris CChris C
1
New contributor
Chris C is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3
- 1 (1) line-oriented data, such as your tracebacks, should be formatted as 'code' in Stack, not normal text which makes it basically unreadable; see the help in the editor window (I fixed for you this time) (2) that exception text is clearly wrong; someone was either incompetent or lazy, because 'not installed' is NOT the only cause of import failure, and it is not the cause here, instead some inconsistency in urllib3 is, but I can't match what you're getting to the urllib3 source in github; what versions of requests and urllib3 do you have installed? ... – dave_thompson_085 Commented Feb 8 at 9:38
- 1 ... (3) the module status on pypi shows this as deprecated 6 years ago (apparently very soon after the blog you read was written) so it hasn't been supported for a while and unsupported things tend to break in weird, complicated, and hard to fix ways; this is commonly described, figuratively, as 'bit rot' – dave_thompson_085 Commented Feb 8 at 9:40
- Thank you for the fix, Dave. And also for pointing out the depreciated module! – Chris C Commented 2 days ago
1 Answer
Reset to default 0Your real error is "ImportError: cannot import name 'Mapping' from 'collections'". The error means that you use code intended for Python up to 3.9 but not for 3.10+ as in 3.10 Mapping
was moved to subpackage collections.abc
.
The bottom line is: use Python 3.9.