由PyInstaller打包到exe后,Errno 185090050 _ssl.c:343:错误:0B084002:x509证书例程:X509_load_cert_crl_file:system lib [英] Errno 185090050 _ssl.c:343: error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib, after packaging to exe by PyInstaller

查看:618
本文介绍了由PyInstaller打包到exe后,Errno 185090050 _ssl.c:343:错误:0B084002:x509证书例程:X509_load_cert_crl_file:system lib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个Python脚本来检查GCS中的文件,它使用wxpython生成GUI.为了进行身份验证,我是以这种方式进行的(遵循Google示例代码中的方法->

I code a python script to check files in GCS, it uses wxpython to generate the GUI. To authenticate I did it in this way(following the way in Google sample code -> http://code.google.com/p/google-cloud-platform-samples/source/browse/file-transfer-json/chunked_transfer.py?repo=storage):

flow = flow_from_clientsecrets(CLIENT_SECRETS_FILE, 
                                # the secrets file I put in same folder
                               scope=scope,
                               message=MISSING_CLIENT_SECRETS_MESSAGE)

credential_storage = CredentialStorage(CREDENTIALS_FILE) # the file to store
                                                    # authentication credentials
credentials = credential_storage.get()
if credentials is None or credentials.invalid:
    credentials = run_oauth2(flow, credential_storage)

self.printLog('Constructing Google Cloud Storage service...')
http = credentials.authorize(httplib2.Http())
return discovery_build('storage', 'v1beta1', http=http)

上面的代码包含在我的Python脚本中,当它只是一个python .py文件时,效果很好,后来我用pyinstaller在win 7 64bit中将其转换为.exe(我也将秘密文件放在了同一个文件中文件夹作为.exe文件),使用以下命令

The codes above are contained in my Python script, which works very well when it is just a python .py file, later I used pyinstaller convert it to .exe in win 7 64bit(I also put the secret file in the same folder as the .exe file) using below command

C:\ gcs_file_check> python pyinstaller-2.0 \ pyinstaller.py -w gcs_file_check.py

C:\gcs_file_check>python pyinstaller-2.0\pyinstaller.py -w gcs_file_check.py

点击exe时,Google的 Permission许可页面已正确启动(就像运行Python脚本而不是exe一样),但是当我单击Accept后,上面的代码将抛出例外:

When clicking on the exe, the Request for Permission page from Google was launched correctly(as what it is as running Python script not exe), but after I click Accept, the above code will throw exception:

[Errno 185090050] _ssl.c:343:错误:0B084002:x509证书 例程:X509_load_cert_crl_file:系统lib

[Errno 185090050] _ssl.c:343: error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib

我可以看到文件 credentials.json 不是由.exe创建的,而Python脚本可以正确创建此文件.

And I can see the file credentials.json is not created by .exe, while the Python script can create this file correctly.

有人能知道这是怎么发生的以及如何解决吗?感谢每个答案!

Could someone know how this happens and how to fix? Appreciate every answer!

==================

===================

于04/16更新:

我添加了调试代码,发现该异常完全来自以下代码:

I added debugging code and found that the exception exactly comes from below code:

if credentials is None or credentials.invalid:
    credentials = run_oauth2(flow, credential_storage)

==================

===================

已更新:

添加更多细节,以前我使用的是 oauth2client.tools.run()

Add more detail, previously I was using oauth2client.tools.run()

from oauth2client.tools import run as run_oauth2

现在,我将建议的源代码更改为run_flow()->

Now I change to run_flow() as the source code suggested -> https://google-api-python-client.googlecode.com/hg/docs/epy/oauth2client.tools-pysrc.html#run

from oauth2client.tools import run_flow as run_oauth2

现在这部分代码是:

parser=argparse.ArgumentParser(description=__doc__,                  
                     formatter_class=argparse.RawDescriptionHelpFormatter,
                     parents=[tools.argparser] )
                     flags = tools.argparser.parse_args(sys.argv[1:])

if credentials is None or credentials.invalid:
    credentials = run_oauth2(flow, credential_storage, flags)

但是仍然,python代码运行良好,并且在通过PyInstaller打包到.exe之后,抛出了相同的异常[Errno 185090050].

But still, the python code works well, and throw the same exception [Errno 185090050] after packaging to .exe by PyInstaller.

推荐答案

尝试一下, https://github.com/kennethreitz/requests/issues/557 当将pyinstaller与Httplib2一起使用时,我也遇到类似的错误. 您需要将ssl客户端证书文件的路径显式传递给'cert'参数http请求.另外,您需要打包. .pem文件作为pyinstaller中的数据文件."

try this, https://github.com/kennethreitz/requests/issues/557 "I also faced a similar error when using pyinstaller with Httplib2. You need to explicitly pass the path to ssl client cert file to the 'cert' argument http request. Also, you would need to package your. .pem file as a data file in pyinstaller."

这篇关于由PyInstaller打包到exe后,Errno 185090050 _ssl.c:343:错误:0B084002:x509证书例程:X509_load_cert_crl_file:system lib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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