我試圖在Google App Engine上使用真棒請求庫。我找到了一個urllib3的補丁,它依賴於與App Engine兼容的請求。 https://github.com/shazow/urllib3/issues/61在Google App Engine中使用請求python庫
我可以成功
import requests
但隨後
response = requests.get('someurl')
失敗,出現以下回溯。這是怎麼回事?
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/admin/__init__.py", line 317, in post
exec(compiled_code, globals())
File "<string>", line 6, in <module>
File "/Users/Rohan/Dropbox/MuktiTechnologiesINC/MuktiTechnologies/GAE/humanmictweet/GAE/libraries/requests/api.py", line 52, in get
return request('get', url, **kwargs)
File "/Users/Rohan/Dropbox/MuktiTechnologiesINC/MuktiTechnologies/GAE/humanmictweet/GAE/libraries/requests/api.py", line 40, in request
return s.request(method=method, url=url, **kwargs)
File "/Users/Rohan/Dropbox/MuktiTechnologiesINC/MuktiTechnologies/GAE/humanmictweet/GAE/libraries/requests/sessions.py", line 208, in request
r.send(prefetch=prefetch)
File "/Users/Rohan/Dropbox/MuktiTechnologiesINC/MuktiTechnologies/GAE/humanmictweet/GAE/libraries/requests/models.py", line 458, in send
self.auth = get_netrc_auth(url)
File "/Users/Rohan/Dropbox/MuktiTechnologiesINC/MuktiTechnologies/GAE/humanmictweet/GAE/libraries/requests/utils.py", line 43, in get_netrc_auth
for loc in locations:
File "/Users/Rohan/Dropbox/MuktiTechnologiesINC/MuktiTechnologies/GAE/humanmictweet/GAE/libraries/requests/utils.py", line 40, in <genexpr>
locations = (os.path.expanduser('~/{0}'.format(f)) for f in NETRC_FILES)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 260, in expanduser
userhome = pwd.getpwuid(os.getuid()).pw_dir
AttributeError: 'module' object has no attribute 'getuid'
可能重複[要求:HTTP人類 - python-requests.org在谷歌應用程序引擎(http://stackoverflow.com/questions/9604799/requests-http-for-humans-python-requests- org-on-google-app-engine) – 2012-04-07 18:06:48