cx_Freeze错误模块SSL不可用Python 3.7 Windows 10

时间:2018-09-26 13:31:09

标签: windows-10 cx-freeze python-3.7

我用Python 3编写了一个程序来制作Bot到Crypto货币的板。该程序运行正常,没有错误,但是使用cx_Freeze时,coinmarketcap查询出现错误,错误是缺少SSL模块。

import sys
from cx_Freeze import setup, Executable
import os
import requests.certs

packages = ["tkinter", "requests", "idna", "queue", "coinmarketcap", "requests_cache", "PIL", "urllib3", "OpenSSL", "ssl", "arrow", "tempfile", "json", "locale", "C:\\Users\\cavaud\\Desktop\\botTKinker\\config", "time", "sys", "MySQLdb", "urllib.request"] 
includeFile = [requests.certs.where(), "cacert.pem", "ico24x24.ico" , "bas.png", "haut.png", "egal.png", "level.png", "logoBotV2H2.png", "orderNOK.gif", "orderOK.gif", "C:\\Users\\cavaud\\AppData\\Local\\Programs\\Python\\Python37-32\\DLLs\\tcl86t.dll", "C:\\Users\\cavaud\\AppData\\Local\\Programs\\Python\\Python37-32\\DLLs\\tk86t.dll"]


path = sys.path
os.environ['TCL_LIBRARY'] = "C:\\Users\\cavaud\\AppData\\Local\\Programs\\Python\\Python37-32\\tcl\\tcl8.6"
os.environ['TK_LIBRARY'] = "C:\\Users\\cavaud\\AppData\\Local\\Programs\\Python\\Python37-32\\tcl\\tk8.6"
os.environ['REQUESTS_CA_BUNDLE'] = "cacert.pem"
base = None
if sys.platform == "win32":
    base = "Win32GUI"

options = {  "path": path,
        "includes": includeModule,
        "include_files": includeFile,
        "packages" : packages,
        "silent": False
       }

options["include_msvcr"] = True        

cible_1 = Executable(
    script="botTK.py",
    base=base,
    icon="ico24x24.ico"
    )

setup(
    name="BotTK",
    version="1.00",
    description="BOT TK",
    author="moi",
    options={"build_exe": options},
    executables=[cible_1]
    )

谢谢

1 个答案:

答案 0 :(得分:0)

尝试如下修改您的setup.py脚本:

includeFile = [(requests.certs.where(), "cacert.pem"), "ico24x24.ico" , "bas.png", "haut.png", "egal.png", "level.png", "logoBotV2H2.png", "orderNOK.gif", "orderOK.gif", "C:\\Users\\cavaud\\AppData\\Local\\Programs\\Python\\Python37-32\\DLLs\\tcl86t.dll", "C:\\Users\\cavaud\\AppData\\Local\\Programs\\Python\\Python37-32\\DLLs\\tk86t.dll"]

(请注意前两个条目的括号!),

os.environ['REQUESTS_CA_BUNDLE'] = os.path.join(os.getcwd(), "cacert.pem")

请参见Requests library: missing SSL handshake certificates file after cx_Freeze