Hello everybody.
I have a small python project and want to make it to single executable file. I am using...
Windows 7
Python 3.4
PyInstaller 3.2.1
My PyInstaller command is,
PyInstaller -y -w -F -n output_file_name --uac-admin --clean source_file.py
this command works properly. But single output file does not ask for admin rights when executed. And there's no shield mark on executable file icon.
When remove the -F option (equivalent to --onefile), output executable file has shield mark on its icon and ask me admin rights. But this is not what I want. I want a single executable file.
I found a manifest file (output_file_name.exe.manifest) in dist\output_file_name folder. So I did...
PyInstaller -y -w -F -n output_file_name --manifest output_file_name.exe.manifest --uac-admin --clean source_file.py
But this command doesn't work. Its single executable file still does not ask for admin rights.
I have removed PyInstaller and installed recent development version.
pip install git+https://github.com/pyinstaller/pyinstaller.git#develop
But the result is same. Its output doesn't have a shield mark on icon and does not ask admin rights.
Do you have any idea?
Please help me!
I found what's wrong!
The key point is...
Install PyInstaller 3.0
Manifest file must be located in dist folder where single excutable file located
The name of manifest file must be same as output file.
If manifest file is located in dist folder, no need to specify --manifest option. --uac-admin is enough.
You can find manifest file at build folder.
Thank you.
Adding up passion053's answer, in my case I used -F instead of --onefile and it works fine for me but yeah you need to add manifest file in the same directory as your single executable.
Note: I used pyinstaller version 3.5. and it works fine for my
Happy Coding!
Adding -r prog.exe.manifest,1 to pyinstaller command line worked for me, after that no need for putting manifest file near exe, pure single exe file.
Related
I wrote a simple code in python/pygame, and the game was running fine in both sublime text and cmd, but when I tried to make it a exe file pyinstaller --onefile version2.py, I got an error and I don't know what is the problem ?
Well bro, I don't know if I will be helpfull to you know after 6 days, I am having 2 solutions for you which worked for me today.
Disable Antivirus OR put that folder in which you are building app.exe to Exception, like I have done below [Mandatory Process].
Dont' run pyinstaller command from the directory where app.py application is present.
a) Get out from that directory/folder
b) Create new directory/folder
c) Enter that directory and start cmd in that directory/folder by pressing (shift + MouseRightClick )
d) And then run the command
pyinstaller --name "MyApp" "python script file path of which you want to create .exe file"
Where "MyApp" is the name which you want to give to the file after it is build successfully
For Example
pyinstaller --name "FileRenamer" "G:\data\python\Project\Bunch File Renamer\rename.py"
Try to disable the anti-virus, that worked for me
I have a python file I am converting to exe via Pyinstaller. The coversion runs fine with no error, however when I run the exe file I get error in line 13 of the python file (line is import librosa). Then I get a bunch of files and then a
FileNotFoundError: No file or directory: 'C:\\Users\\johnny\\Appdata\\Local\\Temp\\_MEI70722\\librosa\\util\\example_data\\registry.txt'.
Also the python file itself runs fine.
Any help would be appreciated
PyInstaller tries to find all the dependencies, however this file is not imported but loaded so it misses it. You can simply force it to add it:
--add-data [path to your python]/Lib/site-packages/librosa/util/example_data;librosa/util/example_data
With The full command be like :
pyinstaller --onefile [YourScript].py --add-data [path to your python]/Lib/site-packages/librosa/util/example_data/registry.txt;librosa/util/example_data
You'll need to specify the data files as PyInstaller hooks.
Create a folder "extra-hooks", and in it a file "hook-librosa.py"
paste these 2 lines in "extra-hooks/hook-librosa.py":
from PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files('librosa')
Then tell PyInstaller where to locate this file with adding 1 of the following to your PyInstaller command:
--additional-hooks=extra-hooks
--additional-hooks-dir "[PATH_TO_YOUR_PROJECT]/axtra-hooks"
The 2nd one worked for me, and I was using auto-py-to-exe, built on PyInstaller.
I guess the file doesn't exist. Open a file manager and copy the directory.
In the PyInstaller, you should type in the python file's name and then --onefile. It makes an .EXE file (if you are on windows) with all the imported files within. You can learn more here: https://pyinstaller.readthedocs.io/en/stable/usage.html
I have cloned a github repository - pypastry - onto my Windows machine, and run pip install -e pypastry to install it in my virtual environment, so the project structure is like this:
│-- pypastry
|-- venv
|-- Scripts
|-- pastry
The executable file, called 'pastry', is sitting in venv\Scripts as I would expect, but Command Prompt isn't recognising it, and I am receiving the error:
'pastry' is not recognized as an internal or external command, operable program or batch file
I don't think it's a problem with PATH as the first item in PATH is C:\Users\User\Documents\pypastry\venv\Scripts.
This is the executable file itself:
#!c:\users\user\documents\pypastry\venv\scripts\python.exe
# EASY-INSTALL-DEV-SCRIPT: 'pypastry==0.0.1','pastry'
__requires__ = 'pypastry==0.0.1'
__import__('pkg_resources').require('pypastry==0.0.1')
__file__ = 'C:\\Users\\User\\Documents\\pypastry\\pypastry\\pastry'
with open(__file__) as f:
exec(compile(f.read(), __file__, 'exec'))
Can anyone spot anything in this file which might mean it's not recognised as an executable on Windows or think of anything else that could be going wrong?
EDIT TO ADD:
If I run the file with the explicit python invocation (python pypastry\pastry) it works, but I don't want to have to do this as it creates other issues.
Windows is telling you that it does not find an executable called "pastry" (pastry.exe, pastry.com, pastry.bat, pastry.cmd ...) on your PATH.
But pastry.py is. Isn't it? The problem is that your windows is not configured to recognize .py as an executable extension.
To run python scripts in Windows without the explicit invocation of python.exe, you need first to have the .py extension associated to the executable python. And then the .py extension added as an executable extension.
You do so in three steps:
Associate the .py extension to a PythonFile file type
ASSOC .py=PythonFile
Associate the PythonFile to your python.exe executable
FTYPE PythonFile="c:\users\user\documents\pypastry\venv\scripts\python.exe" "%1" %*
Associate the .py file extension as one of the default executable extensions
SET PATHEXT=.py;%PATHEXT%
I am using python 2.7.11 and I have downloaded setuptools-2.2 for its included setup.py file. Then I did a python setup.py install (This command is successful), and I added the path for this setup.py file to ~/.bash_profile.
export PATH=/opt/python2711/lib/python2.7/site-packages/:$PATH
export PATH=/path-to-setuptools/setuptools-2.2/:$PATH
However, when I tried to install another software (./pybombs install uhd), my computer kept complaining:
Build failed. Re-trying with reduced makewidth and higher verbosity.
python: can't open file 'setup.py': [Errno 2] No such file or directory
I actually tried to add the path of that egg file as well, but it couldn't help either. I don't know much about this setup.py file. Could somebody point out how to fix this compiling error?
Thanks in advance!
add your path in ~/.profile
export PATH=$PATH:/path/to/dir
~/.profile: executed by the command interpreter for login shells.
how ever the path variable is in
/etc/environment : file open and add the path here you should log in as root
This problem started while I was installing pyswip and needed to run a setup.py file. Using the command "python setup.py", I'm greeted with the following message: "python: can't open file 'setup.py': [Errno 2] No such file or directory."
I know this question's been asked a lot before, so I've tried everything in previous answers. Including #!/usr/bin/env python or #!/usr/bin/env python-3.3.0 at the very top of the script and then trying "chmod +x setup.py"
gives the following: "chmod: cannot access setup.py': No such file or directory".
Trying to run other .py files from the terminal gives the same result.
Running the file in the Python Shell from IDLE doesn't do anything.
Running the "ls -d */" command shows that the Python-3.3.0/ directory, where the .py files in question are, is definitely there.
Am I missing something really obvious? (If it helps, I have Elementary OS 0.2.)
When you run python setup.py that requires the setup.py file to be in the current directory.
You can control the current directory with the cd command.
So:
cd /home/acacia/Python-3.3.0/PySwip/pyswip-0.2.3
python setup.py install
I have no knowledge about Elementary OS but you could try to use the full path of the setup.py.
python /home/acacia/Python-3.3.0/PySwip/pyswip-0.2.3/setup.py install
[EDIT] Can't answer comments, so I just added the install parameter in my answer
You need to go into the directory that you are going to "setup". For example, if you are installing numpy, and you have git-cloned it, then it probably is located at ~/numpy. So first cd into ~/numpy, and the type the commend like "python setup.py build" there.