Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Converting py to exe
#1
Hi all,
I am using PyInstaller to convert a python script to a windows exe file.
The python script is:
#!/usr/bin/python

import requests
import random
import time
import datetime
from datetime import date
import csv
import sys
import lxml.html
import pandas as pd
from bs4 import BeautifulSoup as bs
import json
import xlwings as xw
import schedule
import os


symbol = "XAUUSD"

file = 'C:\\Users\\Admin\\Desktop\\MyFxBookAPIData.xlsm'

try:
    wb = xw.Book(file)
    sht1 = wb.sheets[0]
    sht1.copy(name = symbol)    # copy the template to a new sheet
    sht1 = wb.sheets[symbol]
    cellA = sht1.range('A2')
    cellA.value = sht1.name

except Exception as e:
    print(str(e))
    time.sleep(60)

This works perfectly as a python script but when I convert to exe and run the file I get this error:

(-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147352565), None)

Any ideas please?
Reply
#2
Hello, I just created a script with tkinter and want to use pyinstaller to create an executable file. It all works, except, when I open the file I get

/Users/*********/dist/python\ Script ; exit;
Traceback (most recent call last):
File "python Script.py", line 2, in <module>
NameError: name 'tkinter' is not defined
[16411] Failed to execute script 'python Script' due to unhandled exception!

I am on a Mac and using terminal.
Any ideas?
Reply
#3
I think the subject of converting py to exe files is obviously a very difficult one even for the gurus judging by the number of replies!
Reply
#4
Even non-guru's would like to know what command line you are using:
something like pyinstaller --clean -- windowed ...etc
Paul
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Reply
#5
(Apr-19-2024, 08:50 AM)DPaul Wrote: Even non-guru's would like to know what command line you are using:
something like pyinstaller --clean -- windowed ...etc
Paul

ah ok. So I installed auto-py-to-exe then ran this from the console. It says it converts successfully but when I run the exe file it starts to run i.e the Excel file opens which is a good start then it shows the error message in the console. So it maybe doesn't like the range command in the py script.
Reply
#6
Doesn't matter if you use auto py to exe or pyinstaller. What arguements did you use to make the exe?

Is your posted code the real code that generated the error? Why all the unused imports?
Reply
#7
(Apr-19-2024, 02:07 PM)deanhystad Wrote: Doesn't matter if you use auto py to exe or pyinstaller. What arguements did you use to make the exe?

Is your posted code the real code that generated the error? Why all the unused imports?

yeh I know about imports - just a file I used a few times.

if you know auto py a console window comes up and you choose a few options.

'one file'
'console'
all other options ticked.

sorry don't know how to paste an image in here - it asks for a url???
Reply
#8
What about 'C:\\Users\\Admin\\Desktop\\MyFxBookAPIData.xlsm'? Did you include that as an extra file?
Reply
#9
(Apr-19-2024, 03:37 PM)deanhystad Wrote: What about 'C:\\Users\\Admin\\Desktop\\MyFxBookAPIData.xlsm'? Did you include that as an extra file?

yes tried that but still get same error message
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020