ca_certs_locater / __ init__.py导入错误

时间:2015-11-15 03:43:00

标签: python api ca httplib2

我正在尝试验证我的api.However,它总是显示以下导入错误:

public_key=raw.input ('...')

secret_key=raw.input ('...')

client = upwork.Client(public_key, secret_key)

它应该显示为网址,但它显示

" File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/upwork/client.py", line 118, in __init__
    ca_certs=ca_certs_locater.get(),

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ca_certs_locater/__init__.py", line 36, in get
    raise ImportError()" 

我不知道我应该怎么做ca_certs_locater

2 个答案:

答案 0 :(得分:1)

在实例化升级客户端之前,请修改模块的LINUX_PATH常量。

import upwork

# Set the certificate path within the module
upwork.ca_certs_locater.LINUX_PATH = '/path/to/my/cert.crt'
...
client = upwork.Client(public_key, secret_key, **credentials)
...

答案 1 :(得分:0)

我有同样的问题。解决方案确实正如评论所建议的那样Python - SSL Issue with Oauth2https://pypi.python.org/pypi/python-upwork上的“SSL证书注释”结合使用。我做了以下事情:

  1. 阅读https://github.com/upwork/python-upwork/issues/9
  2. Python - SSL Issue with Oauth2
  3. 下载了cacert.pem
  4. 将HTTPLIB_CA_CERTS_PATH环境变量设置为/path/to/cacert.pem
  5. 然后,导入错误就消失了。我的用例是upwork API,你的用户可能会有所不同,但无论哪种解决方案都是相同的。