Google Cloud Function-AttributeError:“模块"对象没有属性"DEFAULT_MAX_REDIRECTS" [英] Google Cloud Function - AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS'
问题描述
我正在使用Appengine cron作业来计划云功能,并且当我部署并尝试运行作业时,出现了以下错误.知道这里有什么问题吗?从[这里] [1]
I'm using Appengine cron job to schedule cloud function and when I deploy and try to run a job, getting below error. Any idea what could be wrong here? Followed steps from [here][1]
(/base/alloc/tmpfs/dynamic_runtimes/python27/a7637d5531ec9deb_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py:263)
Traceback (most recent call last):
File "/base/alloc/tmpfs/dynamic_runtimes/python27/a7637d5531ec9deb_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/alloc/tmpfs/dynamic_runtimes/python27/a7637d5531ec9deb_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/alloc/tmpfs/dynamic_runtimes/python27/a7637d5531ec9deb_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/s~zion-hymns/20180222t221057.407849847593018575/main.py", line 18, in <module>
import pubsub_utils
File "/base/data/home/apps/s~zion-hymns/20180222t221057.407849847593018575/pubsub_utils.py", line 24, in <module>
import oauth2client.contrib.appengine as gae_oauth2client
File "./lib/oauth2client/contrib/appengine.py", line 36, in <module>
from oauth2client import client
File "./lib/oauth2client/client.py", line 39, in <module>
from oauth2client import transport
File "./lib/oauth2client/transport.py", line 255, in <module>
redirections=httplib2.DEFAULT_MAX_REDIRECTS,
AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS'
[1]: https://firebase.googleblog.com/2017/03/how-to-schedule-cron-jobs-with-cloud.html?utm_campaign=culture_education_functions_en_06-29-17&utm_source=Firebase&utm_medium=yt-desc
推荐答案
似乎我找到了问题.您的pip
使用的是哪个Python版本?就我而言,它是3.6
,尽管Python本身是2.7
Seems that I found the problem. Which version of Python your pip
is using? In my case it was 3.6
despite the fact that the Python itself was 2.7
因此,问题在于pip
下载了Python 3.6
语法版本的httplib2
,并将其上传到使用Python 2.7的Google App Engine.它试图加载到模块中,但失败了.
So the problem was that pip
downloaded a Python 3.6
syntax version of httplib2
, it was uploaded to the Google App Engine, which use Python 2.7. It tried to load in the module and fail miserably.
尝试一下:
- 使用以下命令检查您的点的vesionn:
点-V
如果您看到/bla/bla/lib/python3.6/site-packages (python 3.6)
中的pip 9.0.1之类的内容,请继续
If you see some thing like pip 9.0.1 from /bla/bla/lib/python3.6/site-packages (python 3.6)
then continue
-
为python 2.7安装
pip
(应该在bin文件夹下的Python2.7安装包中)
Install
pip
for python 2.7 (it should be in the Python2.7 installation pachage under bin folder)
删除项目中的旧lib
文件夹
运行pip install -t lib -r requirements.txt
(确保此pip是正确的2.7
版本)
Run pip install -t lib -r requirements.txt
(make sure that this pip is the right 2.7
version)
部署
这样做可以使用正确版本的lib,它应该可以正常工作.
By doing that you are using the right version of the lib and it should be working.
希望这会有所帮助.
这篇关于Google Cloud Function-AttributeError:“模块"对象没有属性"DEFAULT_MAX_REDIRECTS"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!