Python py2exe with tkinter (pyw file) - python-3.x

I have made a small program in Python that involves tkinter, and I made it a pyw file because it has a shortcut on the desktop and I do not want the command prompt to get in the way. I used py2exe following the sentdex tutorial on youtube, and I got an output file, but the output file shows an error and exits before I can read it. The pyw file on its own works fine, but I don't know how to get the exe output file to work correctly.
Information:
Python - 3.4.2;
OS - Windows 8.1;
Folder - Multiple items (photos and audio for the program);
Program - A simple animation in tkinter
If you need the program, tell me and I can upload the folder containing the program.

As far as I understand there is not a version of py2exe for python3.x
You'd be best of going for cx_freeze (Sentdex also has a tutorial on that on that)

Related

.exe doesn't work after converting from .py with auto-py-to-exe

everyone!
I'm new in programing.
I faced the problem that my .exe doesn't work after I converted it from .py file.
File is prety simple. It's load data from excel to scv using pandas and time just for the logs.
I haven't caught any errors during the convrting proccess, but when I open .exe, it shows only terminal with flickering cursor.
I also add "--exclude-module" for other instaled modules which wasn't used in my program. It helped decrise size of the end .exe file, but still it doesn't work.
If you have any ideas, please share with me.
I found the solution in this answer https://stackoverflow.com/a/71626038/17618130 Basicly it offers to use raw Pyinstaller without auto-py-to-exe But i'v found that it is still working only on windows server, but don't work on Windows 10. So I still need help(

Linux Ubuntu how to start standard application scribus from python eclipse anaconda

I edited my question, hope it is described better now.
I am working on a software that gives me a nice PDF with lots of matplotlib graphics, depending on the data I get.
So think of a database of pages and then the software decides which pages are chosen and filled with changed images, The text stays the same.
So for instance for data1 I get page1-4 and page7 and page 9. For data2 I get page1-4 and page6. Saved as PDF. I am doing this manually with Quark which needs to be changed. I hope I can figure out the scripting to do so.
But for starters I cant start scribus from the developing enviroment. Eclipse Anaconda on Ubuntu.
import subprocess
subprocess.run('scribus')
works fine in terminal, but gives me an error in Eclipse which I cant figure out.
File "/home/b256/anaconda3/envs/test/lib/python3.7/site.py", line 178
file=sys.stderr)
^
SyntaxError: invalid syntax
This seems to be some Python 2 error in the site.py file
???? Is this some anaconda python path error ??
It's not really clear to me, what you want to achieve, but you're welcome to have a look at a script of mine:
https://github.com/aoloe/scribus-script-repository/blob/master/imposition/imposition.py
This is probably a bit more complex than what you are trying to achieve:
the script gets started from the terminal,
if it notices that it has not been started from inside of Scribus (the exception on import scribus)...
... it starts Scribus with itself as the Script to be run.
the script runs again, this time from inside of Scribus...
... now there is no exception when importing scribus and the body of the script runs.
Of course, it's simpler if you start a script that launches Scribus with other scripts.
For you the most important line is probably:
call(['scribus', '-g', '-py', sys.argv[0]] + arguments + ['--', file])
It's starting Scribus from Python
with as little GUI as possible (-g) and
launches the script sys.argv[0]
with a few arguments and
after the -- tells Scribus what file to open.

Mac executable not working when downloaded online

I have made a small (8 MB) program into a MAC executable (.app?)
It works great if I share it using a thumbstick, but if I try to upload it to google drive and then download it it doesn't work. By this I mean It first tells me that It is an unidentified source (this seems reasonable)
But then if I click "open"
It opens as a text file with junk data:
If I try to force it to open on the terminal, how the other program opens, it just shows the heartbeat thing that MACs do when opening a file, but never opens anything.
It is certifiably the same exact file. Same size, same name, same goobldygoop if I open both of them as text files instead of executables.
I am really confused, the only thing I can think of is the "signature" that apple uses is lost when it is compressed into a zip, but I'm probably totally off base.
The code uses python 3.7, pyinstaller, pynput, and selenium.
I am using MAC OS Catalina to write and make into an EXE, then another Catalina to try to run the program.
EDIT: Clarify what doesn't work means
Please help.
I found the answer, simply zip the file from my mac and send it that way!
Yay!

I have tried many methods and I couldn't find solution. So how to convert Python file to executables?

Python : 3.5
PYinstaller : 3.5
Win64
cx_Freeze : 6.0
According to the above information, I have tried to convert Python project to exe but it does not work.
First I have tried pyinstaller but the process throw some error:
After that, I have tried cx_Freeze and it works, but the exe are working on some computer but not on every computer that have same platform.
I don't know what I can do. I looked for google and stackoverflow but there are unsolved problems or I couldn't see the solution.
Later I have tried to change python version but doesn't work again. Computers that have tried to running the exe, have same OS platform, I'm sure.
By the way, if you receive the following cx_Freeze error, resolving like this:
Build\exe.win-amd64-3.7\lib\scipy\spatial\cKDTree.cp37-win_amd64
change to
Build\exe.win-amd64-3.7\lib\scipy\spatial\ckdtree.cp37-win_amd64
Program uses the following modules : tkinter, pydicom, skimage, PIL, cv2, etc.
Primarily Program has 2 page that content code but I made single file for I came across this sentence "It's worth noting that pyinstaller can compile to a single .exe file"
What do you suggest I do? Thanks for your help.
Edit: I have been tried "Auto-py-to-exe" but I got an error (Fatal Error : Failed to execute script")
Edit2: I tried to run outside the anaconda. I think its work. But I'm still testing.
Edit3: I have tried to change python version, GUI was opened another computer but the program is not work properly. the program works on my computer but not on another computers
If you are not able to convert python file to executable format, you can try using auto py-to-exe library.
This library contains a GUI format to convert .py files to .exe
Here you can find auto py-to-exe with usage instructions,
https://pypi.org/project/auto-py-to-exe/

Trying to open a python file in IDLE. Instead, a pycache folder is created. How do I fix this?

I have a number of python files with .py extensions that I was working on, closed, and tried to come back to later. When I tried to open them by right clicking and selecting “Edit with IDLE,” instead of opening a pycache folder was created.
I have a work around in which I go to edit the file with Notepad++, copy the text into a new python editor, delete the old file, and resave the new file with the same name. My research has turned up questions related to pycache and IDLE, but none specifically addressing the issue. Has anyone encountered a similar problem/know how to solve it? I’m running Python 3.5.2 on Windows 7.
What did you name the .py file as? If you named it something like "string.py", Python might interpret the file as one of those in the "Lib" folder. Why you can resave it with the same name and have it working afterwards is anyone's guess. I suggest just renaming the python file to something else.
I developed the bad habit of writing/editing python files with IDLE from watching intro videos when I was still relatively new to programming. I have since learned that file editors like Sublime or IDE's like PyCharm are a significantly better way to go and would highly recommend anyone reading this.
I had a similar issue. When I clicked "Edit with IDLE 3.6", it would create a "pycache" folder and not open the python file on IDLE.
I found a Reddit thread that gives an explanation here.
The reason the pycache folder is created is as follows:
When you import a module, Python stores the compiled bytecode in that
directory so that future imports can use it directly, rather than
having to parse and compile the source again. It does not do that for
merely running a script, only when a file is imported.
No such folder is created for the standard library, as the standard
library is pre-cached when you install Python
I was importing Python's "random" library, in another python file (placed in the same directory). So the issue was solved once I deleted that file.

Resources