getting a spec file instead of a exe with pyinstaller [duplicate] - python-3.x

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

No Python Folder in " Documents "?

im trying to learn python from a video. The first step is to install and to go to Documents/Python where he has a bunch of files. I do not however have that folder. Cant find it on google so far either. Any help would be appreciated. Thank you so much.
https://youtu.be/myFD0np9eys?t=219 <-- Video
You don't have that folder because that's a folder he created to put all of his python programs (that he has already made) into. Please watch further into the video and/or watch the video more closely. He is simply showing you how to navigate your computer using the Command Prompt by using the cd command.
In the video, he changes the current working directory using cd. In his case, all of the python files that show up are the ones he has personally created in his Documents folder. You simply just have to navigate to wherever you save the python files you want to run. For example, if you have a folder on your desktop called "PythonProjects" and within that folder you have a python script titled "foo.py," you would type in the command prompt / terminal:
cd Desktop/PythonProjects
Then to run the file:
python foo.py
Maybe you can try searching for cmd commands to search for the folder, plus there's not really any reason to open the Python folder as you can save all your work in a new folder in the desktop if you make one
In the video he has put all of his python programs and modules in a folder called Documents , hence he is getting the list of files , not necessary that you would have those files in the first place as he has downloaded a lot of packages , you might have a default location which is generally.
C:\Users\username\Appdata\Local\programs\python\python38-32
And not one more thing the python38-32 in the location i specifeid is my python version (python 3.8) if urs is python 3.7 you may want to enter python37-32 instead . Hope this answer helps you .

Hide input files during the conversion of python scripts into exe

I have python scripts in folder A and some dependent input files (.xlsx,.txt) in folder B.
I am using cx_Freeze to convert them into exe.
I have the files in the folder B as a list in include_files in setup.py
During the conversion, the files fall in the build folder.
The files should not be visible to the user, or at least they should be only in read-only mode.
You can use os.chmod at the end of your setup script to make any file of the build directory read-only. For example:
import os
import stat
os.chmod(path_to_file, stat.S_IREAD)
Of course you need to know the path to the build directory. You can also tell cx_Freeze which directory to use as build directory by using the build_exe option of the build_execommand, see the cx_Freeze documentation.

Pyinstaller adddata query

When I am trying to converting my python file into executable and binding with pdf with using command add-data. My pdf file is store no where due to this I cannot open my pdf file while opening executable.(yes, but command will create executable properly but there storing of pdf in default temp directory).
command:
pyinstaller.exe --add-data src;. --onefile python_file.py
P.s:- I tried to popen my file through my code but pdf is storing nowhere so, I cannot execute popen command
The documentation of pyinstaller is here: https://pyinstaller.readthedocs.io/en/stable/usage.html
and syntax of this command is:
--add-data <SRC;DEST or SRC:DEST>
Additional non-binary files or folders to be added to the executable. The path
separator is platform specific, os.pathsep (which is ; on Windows and : on most unix
systems) is used. This option can be used multiple times.
It means that for each folder of data you need use this parameter once. SRC is path in your system. DST is path relative to your bundle root. I suggest do not use --onefile when you have some problem with build. Then you can easier inspect resulted build.

How to include all necessary files and folders in python executable file using pyinstaller on ubuntu?

I want to keep all the python script files hidden and want to give executable file to the user.
Here's the screeenshot of the folder:
I am running it from the webroot directory of a project.I am going to run my project on the local host. In the Al3ViewerController I have given path to the main.py/ exe main file using shell_exec. But I need to keep the folder containing all the other python and DB files and I cannot do that for code security purpose, hence an exe file to run. could be --onefile / folder. I would want to remove that folder completely and just run from the executable file

Running .jar File on Linux

I have a .jar file that reads two files from within its current folder and produces as output a .txt file and a separate folder with multiple other .txt files. This works perfectly in Windows using this code to create the directory:
static String dir = System.getProperty("user.dir");
I used the instructions here: https://askubuntu.com/questions/192914/how-run-a-jar-file-with-a-double-click to set up my .jar file to run on a simple double-click, but as of right now, it does nothing when double-clicked. My guess is that the above line of code does not translate well to Linux. Anybody know how to resolve this?
First, try running it on the command-line, with
java -jar <file.jar>
The user.dir property is cross-platform (see here) so it should not be the problem. However, are you using correct file separators? Remember it's '/' on UNIX and '\' on Windows.
Try java -jar Jarname.jar and pass other files as arguments after this command
The code line you gave works fine on linux.
My best guess is that you're then trying to use this directory path by adding a windows-specific path separator (like path + "\subdir") which isn't appropriate for linux (you should build a new File object instead).
Either that, or your jar file isn't being executed at all. Have you tried doing something very simple in your jar file to see if anything is being run? Have you tried running your jar with java -jar myapp.jar to see if any exceptions are thrown or error messages displayed?
You will need to manually tweak your build process to get the jar file marked as executable. In your build xml file, there is a target, "-post-jar", that is called after the jar is built. You'll need to make that target and use Ant's chmod task to modify your jar. Once you do that it will occur every time you make a jar file in that project.
It will run fine as long as you have a JRE installed.
Read this article to know more.

Resources