问题
I am trying to run the 'generate_refresh_token.py' file in the authentification folder of the AdWords API.
But when I do python generate_refresh_token.py
as described in the documentation, I get the error ModuleNotFoundError: No module named 'google_auth_oauthlib'
.
So I try to install the module with pip install google-auth-oauthlib
, and here is the output:
Requirement already satisfied: google-auth-oauthlib in /home/$USER/anaconda3/lib/python3.6/site-packages (0.2.0)
I activate my anaconda3 environment by doing source activate /home/$USER/anaconda3/envs/$environment_name
. I try to generate the token again with the command above, same error.
Could not find any useful answer or anyone having the same issue with this module. Does anyone have a suggestion I could try?
UPDATE: I have found the error. When I installed the google-auth-oauthlib module via pip, it was installed as a module in the anaconda3 library. But when I run python from the command line, it uses the version from my system, which doesn't have this module. What I don't understand though is why when I activate my anaconda environment, the python to be used is still that of the system. How can I use the anaconda version of python from the command line?
回答1:
I had the same issue. Was resolved by using:
sudo pip install google-auth-oauthlib
the sudo was necessary, not sure why, maybe someone else can eleborate.
回答2:
If you use conda
instead of pip
:
conda install google-auth google-auth-oauthlib
来源:https://stackoverflow.com/questions/53387781/modulenotfounderror-no-module-named-google-auth-oauthlib