简体   繁体   中英

Problems running Dashku python script on Amazon Linux

I am trying to run a Dashku python script on my Amazon EC2 instance running Amazon Linux.

This is the error I get:

[ec2-user@ip-10-231-47-166 ~]$ python dashku_53dc123bc0f9ac740b009af9.py
Traceback (most recent call last):
  File "dashku_53dc123bc0f9ac740b009af9.py", line 16, in <module>
    requests.post('https://dashku.com/api/transmission', data=json.dumps(payload),headers=headers)
  File "/usr/lib/python2.6/site-packages/requests/api.py", line 88, in post
    return request('post', url, data=data, **kwargs)
  File "/usr/lib/python2.6/site-packages/requests/api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python2.6/site-packages/requests/sessions.py", line 335, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.6/site-packages/requests/sessions.py", line 438, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.6/site-packages/requests/adapters.py", line 331, in send
    raise SSLError(e)
requests.exceptions.SSLError: [Errno 1] _ssl.c:493: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

Note that I calling sudo yum install requests did not do much, but calling sudo yum upgrade python-requests did install it.

The script works find on my local machine and has not been modified at all:

# Instructions
#
# easy_install requests
# python dashku_53dc123bc0f9ac740b009af9.py
#
import requests
import json

payload = {
  "bigNumber": 500,
  "_id": "XXXXXX",
  "apiKey": "XXXXXX"
}
headers = {'content-type': 'application/json'}

requests.post('https://dashku.com/api/transmission', data=json.dumps(payload),headers=headers)

Running it on my local machine works fine and Dashku is updated accordingly.

Any ideas? Thanks.

不知道这是否是合适的解决方案,但可以在requests.post调用中添加verify=False以“解决”问题。

requests.post('https://dashku.com/api/transmission', data=json.dumps(payload),headers=headers, verify=False)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM