Cannot find output folder for .exe file using pyinstaller - python

I am completely new to python and trying to create an application (or .exe) file for python using pyinstaller. I ran the command pyinstaller -[DIRECTORY].py and it saved it to an output directory "C:\Windows\System32\Dist\Foo", however when i tried to locate the directory it did not seem to exist (Dist).
NOTE: i'm trying to convert a .py file to .exe file in Python 3.5
Thanks for any help :)

If you set your command directory to the .py script location and run pyinstaller yourscript.py, it will generate folders in the same location as your script. The folder named dist/ will contain the .exe file.

Could you please try easily the command:
`pyinstaller yourscript.py`
You will get your output folder anyway if everything is correct with your software/module.
Second you can have no rights into System32 folder, so you could try a different folder.
Third you might have inconsistency with the path \ or /.
Hope those three suggestions will lead you to the correct solution :-)
Have a nice day.

Related

I want to compile my python project and i don't know how to do that

I want to compile all this into a python exe
folder and file png
Can you guys give me the full command on how can i compile it
run the main file from the terminal, all files are probably linked through it.
to run the file go to the directory where all of your files are present and type: python main.py

How to avoid python running file in the directory where the code is located?

I'm writing a script that will download an executable from the internet, which will create more files. Now, if I download the file, it will be downloaded to the directory I told it, but when I open it using os.startfile(), it creates the files to the directory where the python script is located. How can I avoid that?
Either you can move the .py file to any other directory.
or
You can use os.chdir() to change the current working directory of the script during the runtime.
os.chdir('/path/to/directory')
Do a os.chdir() before trying to run the executable:
os.chdir('<the target folder where you want the files to be created>')
...
os.startfile('<path to where the executable was downloaded>')

Generate an executable file in python

I have proceeded to generate an executable file using pyinstaller, once it has finished the corresponding files are generated, then:
In my windows console I apply this command: pyinstaller --onefile program_with_excel.py
I use this command to compile everything into a single.exe file, so that I can use it on another pc.
Once this is done, I open my executable located in the 'dist' folder and when doing so I have detected several problems:
My executable file 'program_with_excel.exe' is too heavy for what I am trying to do, a few simple calculations. (317,948 KB)
When I open it, the following error appears and then my application closes:
I suspect it is because to run my program I use an excel sheet using 'pandas' where I place data and they are calculated with my program. How could this be resolved?
What would be the solution for this problem and be able to work with my executable?
I also attach a rar with my program and my excel sheet: RAR_EXAMPLE
Best regards.
The exe needs to have access to all its dependencies, just like the python script. If you moved it then it may not have that access. It appears from the error that this is the problem. A common way these exe files are transported is by putting it and each dependency in a zipped folder and using NSIS.

Pyinstaller exectuable using data from other folders?

I've written a program that generates a random name and displays a random image along with it using Python and tkinter. However, I want the user to be able to add and remove pictures as well as edit the names of students. That being said, I don't want to package these inside the executable where it can't be changed by the user.
To use PyInstaller, I go into the command prompt and navigate to the working directory and type:
pyi-makespec --windowed --onefile --icon=Assets\\icon.ico random_student.py
Then, in the spec file I change datas to:
datas=[('Assets\\icon.ico', 'Assets')],
Then, I run
pyinstaller random_student.spec
The program runs just fine using PyCharm. And I've done this exact same method on a couple of other .py files an it works. However, they don't need to pull images/text into their programs. This will create an executable, but I can't run it. It gives me a Fatal Error "Failed to execute script random_student". I've tried placing the executable in the working directory and in the pictures folder, but neither work.
I'm currently using Windows 10 64-bit and Python 3.6.6
I'd appreciate any kind of help I can get with this!
SOLUTION: I removed the --windowed option so I could actually read the error. Then realized I didn't have Pillow installed so it was unable to be packaged. Thank you for the help.

Py2exe (Python Pygame) - Is there not an easier way?

I just checked the wiki and realized you need to input a tonne of code to change a python file containing pygame code to an exe. Is there not an easier way? Shouldn't it just be an exe file that you just open and imput what you want to change and where to save the exe to?
I am not sure I completely understand your question, but I would recommend using PyInstaller. All you have to do it go into the pyinstaller directory, and then run:
python pyinstaller.py /link/to/your/program
which should then make a directory in the pyinstaller directory named after your .py file. In that file you will have a build folder and a dist folder. The dist is the one of interest and will have your .exe in it.

Categories