簡體   English   中英

Errno 185090050 _ssl.c:343:錯誤:0B084002:x509證書例程:X509_load_cert_crl_file:系統庫,在由PyInstaller打包到exe之后

[英]Errno 185090050 _ssl.c:343: error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib, after packaging to exe by PyInstaller

我編寫了一個python腳本來檢查GCS中的文件,它使用wxpython來生成GUI。 要進行身份驗證,我是這樣做的(按照Google示例代碼中的方式 - > 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將它轉換為.exe在win 7 64bit(我也把秘密文件放在同一個文件夾中) .exe文件)使用下面的命令

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

當點擊exe時,Google的“ 權限請求”頁面正確啟動(就像運行Python腳本而不是exe腳本一樣),但是在我單擊“Accept”之后,上面的代碼將拋出異常:

[Errno 185090050] _ssl.c:343:錯誤:0B084002:x509證書例程:X509_load_cert_crl_file:system lib

我可以看到文件credentials.json不是由.exe創建的,而Python腳本可以正確創建此文件。

有人知道這是如何發生的以及如何解決? 感謝每一個答案!

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

2016年4月16日更新:

我添加了調試代碼,發現異常完全來自以下代碼:

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

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

更新:

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

from oauth2client.tools import run as run_oauth2

現在我改為run_flow()作為源代碼建議 - > 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]。

試試這個, https://github.com/kennethreitz/requests/issues/557 “在使用帶有Httplib2的pyinstaller時我也遇到了類似的錯誤。你需要顯式地將ssl客戶端證書文件的路徑傳遞給'cert'參數http另外,您需要將.pem文件打包為pyinstaller中的數據文件。“

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM