Python Forum
convert a .py file to .exe file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
convert a .py file to .exe file
#1
Hi i made a pyttsx3 python program which is executed in the run-time but when i convert it into exe it doesn't work.
my code was:-
[
import pyttsx3
engine = pyttsx3.init()
engine.setProperty('rate',120)
engine.say('hello how are you')
engine.runAndWait()
]
then i used pyinstaller to convert it.
Reply
#2
(Nov-21-2019, 04:40 AM)vigneshboolog Wrote: then i used pyinstaller to convert it.

which command did you use?
Reply
#3
pyinstaller filename.py
Reply
#4
try auto-py-to-exe
Reply
#5
tried that to
Reply
#6
probably pyinstaller failed to find some hidden imports
https://pythonhosted.org/PyInstaller/whe...wrong.html
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#7
Did a test you most include drivers.sapi5.
Here is the spec file,you can run it bye using:
pyinstaller --clean talk_fix.spec
talk.py is your code talk_fix.spec is spec file posted under.
Change pathex to folder you run from.
# -*- mode: python ; coding: utf-8 -*-

block_cipher = None


a = Analysis(['talk.py'],
             pathex=['E:\\div_code\\forum_env'],
             binaries=[],
             datas=[],
             hiddenimports=["pyttsx3", "pyttsx3.drivers.sapi5"],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          [],
          name='talk',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          upx_exclude=[],
          runtime_tmpdir=None,
          console=True )
Reply
#8
1) I added the drivers.sapi5 line to my code
2) Then i made a spec file with code above in the same folder
3) The in command line i entered pyinstaller --clean talk_fix.spec
4) the error came ' (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape'
Reply
#9
(Nov-28-2019, 01:51 PM)vigneshboolog Wrote: 1) I added the drivers.sapi5 line to my code
You shall not anything to code,only spec file.
# talk.py
import pyttsx3

engine = pyttsx3.init()
engine.setProperty('rate',120)
engine.say('hello how are you')
engine.runAndWait()
Quote:4) the error came ' (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape'
In the build process?
Are you using Python 3.7?
Reply
#10
python 3.8
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question [SOLVED] Correct way to convert file from cp-1252 to utf-8? Winfried 8 839 Feb-29-2024, 12:30 AM
Last Post: Winfried
  file open "file not found error" shanoger 8 1,122 Dec-14-2023, 08:03 AM
Last Post: shanoger
  Need to replace a string with a file (HTML file) tester_V 1 763 Aug-30-2023, 03:42 AM
Last Post: Larz60+
  How can I change the uuid name of a file to his original file? MaddoxMB 2 926 Jul-17-2023, 10:15 PM
Last Post: Pedroski55
  Convert File to Data URL michaelnicol 3 1,167 Jul-08-2023, 11:35 AM
Last Post: DeaD_EyE
  Python Script to convert Json to CSV file chvsnarayana 8 2,514 Apr-26-2023, 10:31 PM
Last Post: DeaD_EyE
  Reading data from excel file –> process it >>then write to another excel output file Jennifer_Jone 0 1,102 Mar-14-2023, 07:59 PM
Last Post: Jennifer_Jone
Thumbs Up Need to compare the Excel file name with a directory text file. veeran1991 1 1,123 Dec-15-2022, 04:32 PM
Last Post: Larz60+
  Convert Excel file into csv with Pipe symbol.. mg24 4 1,329 Oct-18-2022, 02:59 PM
Last Post: Larz60+
Photo Making Zip file of a file and Directory Nasir 2 1,026 Oct-07-2022, 02:01 PM
Last Post: Nasir

Forum Jump:

User Panel Messages

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