pyinstaller编译文件有ssl问题,错误:185090050 [英] pyinstaller compiled file has ssl issue, error: 185090050

查看:204
本文介绍了pyinstaller编译文件有ssl问题,错误:185090050的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在python ide和cmd提示符下的Windows计算机上成功运行了一些python代码.

i've got some python code that's successfully running on my windows machine in the python ide and cmd prompt.

在我用pyinstaller编译(成一个文件)后,出现以下错误:

after i compile with pyinstaller (into one file) i get the following error:

Traceback <most recent call last>:
    File "<string>", line 51, in <module>
    File "build\bdist.win32\egg\oauth2\__init__.py", line 682, in request
    ... ((traceback through httplib2 and then ssl))
ssl.SSLError: [Errno 185090050] _ssl.c:340: error:0B084002:x509 certificates routines:X509_load_cert_crl_file:system lib

导致错误的代码的子集如下:

a subset of my code that's causing the error is as follows:

     import oauth2 as oauth
     import httplib2
     import urlparse

     #consumer inputs
     consumer_key    =   'blah'
     consumer_secret =   'blah'
     consumer = oauth.Consumer(consumer_key, consumer_secret)

     #other inputs
     request_token_url = 'https://api.linkedin.com/uas/oauth/requestToken?scope=r_network'
     access_token_url =  'https://api.linkedin.com/uas/oauth/accessToken'
     authorize_url =     'https://api.linkedin.com/uas/oauth/authorize'

     #instantiate consumer object
     client = oauth.Client(consumer)
     resp, content = client.request(request_token_url, "POST", )

应该是一个简单的api请求!我四处张望,并尝试在代码开头使用以下内容:

should be a simple api request! i've look all over and tried to use the following at the beginning of the code:

    httplib2.Http(ca_certs = 'cacert.pem')

...那没用.

我还用新的cacert.pem(重命名为cacerts.txt)替换了httplib2文件夹中的cacerts.txt文件...但是没有用.

i've also replaced my cacerts.txt file in httplib2 folder with the new cacert.pem (renamed to cacerts.txt)... but that didn't work.

我尝试通过以下方式禁用ssl:

i've tried to disable ssl with this:

    httplib2.Http(disable_ssl_certificate_validation=True)

...但是那没用.

我该如何使用pyinstaller编译python脚本,而又不会混乱呢?

How do I compile my python script using pyinstaller in a way that doesn't mess up?

推荐答案

当我尝试使用OAuth 2.0连接到Google驱动器时,我遇到了同样的问题.我已经搜索并发现解决方案在 init .py这行

I had the same problem when I tried to connect to google drive with OAuth 2.0. I have searched and found that the solution is changing in httplib2 in init.py this line

CA_CERTS = os.path.join(
    os.path.dirname(os.path.abspath(__file__ )), "cacerts.txt")

被其他人

CA_CERTS = os.path.join(os.path.dirname(sys.executable), "cacerts.txt")

然后构建.exe,并将"cacerts.txt"文件放在.exe的同一文件夹中.

then build the .exe and put the "cacerts.txt" file in the same folder of the .exe.

它对我有用,我希望它也对你有用!

It worked for me, I hope it does for you too!

这篇关于pyinstaller编译文件有ssl问题,错误:185090050的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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