Answer the question
In order to leave comments, you need to log in
Py2exe exceptions SSLError how to win?
Compiling a simple python script to exe using py2exe. No errors on compilation, error on startup
requests.exceptions.SSLError: [Errno 2] No such file or directory
# -*- coding: utf-8 -*-
from win32com import client
import telepot
import ConfigParser
import codecs
import os
config = ConfigParser.RawConfigParser()
config.readfp(codecs.open('config.ini', 'r', 'cp1251'))#Задаем имя ini-файла
path = config.get('main', 'path')
chatID = config.get('main', 'chatid')
print (path)
print (chatID)
#Last page xls 2 pdf
xlApp = client.Dispatch("Excel.Application")
books = xlApp.Workbooks.Open(path)
t= books.Worksheets.count # количество листов
print(t)
ws = books.Worksheets[t-1]
n = ws.name # Имя листа
print (n)
report = 'C:\\test\\'+n+'.pdf'
ws.Visible = 1
ws.ExportAsFixedFormat(0, report)
books.Close()
xlApp.Quit()
####telegram
TOKEN = '207266730:AAF5BXGKTIEmS8-RbwCqXPcCKnL7yorhmP4'
bot = telepot.Bot(TOKEN)
f = open(report, 'rb') # some file on local disk
n2 = "Отчет "
n2UTF = unicode(n2, 'utf-8', errors='replace')
Text = n2UTF + n
message = bot.sendMessage(chatID,Text)
response = bot.sendDocument(chatID, f)
print(response)
print report
f.close()
os.remove(report)
Answer the question
In order to leave comments, you need to log in
I solved it, but only did it with cx_Freeze. Everything was solved by writing a small module ca_certs_locater:
import os
import sys
def get():
return os.path.join(os.path.dirname(os.path.abspath(sys.executable if getattr(sys, "frozen", False) else __file__)), "cacerts.txt")
import os
import httplib2
from cx_Freeze import setup, Executable
setup(
name="Name",
version="1.0.0",
description="Description",
options={
"build_exe": {
"packages": [
"ca_certs_locater", ...
],
"include_files": [
os.path.join(os.path.dirname(os.path.abspath(httplib2.__file__)), "cacerts.txt"),
...
],
"excludes": [
"tkinter"
]
}
},
executables=[
Executable("ExecutableFileName.py")
]
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question