ModuleNotFoundError:没有名为"google_auth_oauthlib"的模块 [英] ModuleNotFoundError: No module named 'google_auth_oauthlib'

查看:854
本文介绍了ModuleNotFoundError:没有名为"google_auth_oauthlib"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在AdWords API的身份验证文件夹中运行"generate_refresh_token.py"文件.

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'.

所以我尝试使用pip install 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)

我通过执行source activate /home/$USER/anaconda3/envs/$environment_name激活anaconda3环境.我尝试使用上面的命令再次生成令牌,同样的错误.

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?

更新:我发现了错误.当我通过pip安装google-auth-oauthlib模块时,该模块作为模块安装在anaconda3库中.但是,当我从命令行运行python时,它使用的是我系统中没有此模块的版本.但是我不明白的是为什么当我激活anaconda环境时,要使用的python仍然是系统的python.如何从命令行使用蟒蛇的anaconda版本?

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?

推荐答案

我遇到了同样的问题.通过使用以下方法解决了:

I had the same issue. Was resolved by using:

sudo pip安装google-auth-oauthlib

sudo pip install google-auth-oauthlib

sudo是必需的,不确定为什么,也许其他人可以细细品味.

the sudo was necessary, not sure why, maybe someone else can eleborate.

这篇关于ModuleNotFoundError:没有名为"google_auth_oauthlib"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆