I just finished the first draft of a .ui file in the designer of pyqt, and I am wondering how I go from the .ui file to an exe to let someone test out my ui... I currently have a makefile that translates my .ui file into a .py file, but now I want to go from .py to .exe
Does anybody know how to do this? I have py2exe downloaded but not sure if this is what I want...
Please assume the people I want to test this don't have python downloaded and are using Windows (cross platform is better but windows will be used)
Thank you!
EDIT: when i run py2exe on my test.py (which was made from the test.ui)
I use
py -3.6 -m py2exe.build_exe test.py
and get
C:\Users\Chris\Desktop\makeExe>py -3.6 -m py2exe.build_exe test.py
Traceback (most recent call last):
File "C:\Users\Chris\AppData\Local\Programs\Python\Python36\lib\runpy.py", lin
e 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\Chris\AppData\Local\Programs\Python\Python36\lib\runpy.py", lin
e 85, in _run_code
exec(code, run_globals)
File "C:\Users\Chris\AppData\Local\Programs\Python\Python36\lib\site-packages\
py2exe\build_exe.py", line 145, in <module>
main()
File "C:\Users\Chris\AppData\Local\Programs\Python\Python36\lib\site-packages\
py2exe\build_exe.py", line 141, in main
builder.analyze()
File "C:\Users\Chris\AppData\Local\Programs\Python\Python36\lib\site-packages\
py2exe\runtime.py", line 160, in analyze
self.mf.import_hook(modname)
File "C:\Users\Chris\AppData\Local\Programs\Python\Python36\lib\site-packages\
py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Users\Chris\AppData\Local\Programs\Python\Python36\lib\site-packages\
py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Users\Chris\AppData\Local\Programs\Python\Python36\lib\site-packages\
py2exe\mf3.py", line 357, in _find_and_load
self._scan_code(module.__code__, module)
File "C:\Users\Chris\AppData\Local\Programs\Python\Python36\lib\site-packages\
py2exe\mf3.py", line 388, in _scan_code
for what, args in self._scan_opcodes(code):
File "C:\Users\Chris\AppData\Local\Programs\Python\Python36\lib\site-packages\
py2exe\mf3.py", line 417, in _scan_opcodes
yield "store", (names[oparg],)
IndexError: tuple index out of range
C:\Users\Chris\Desktop\makeExe>
Py2exe didn't support signing whereas Pyinstaller has support for signing from version 1.4
So this is also a solution
pip install pyinstaller
pyinstaller --onefile --windowed test.py
Related
PS C:\Users\user> pyinstaller onefile Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Scripts\pyinstaller.exe\__main__.py", line 7, in <module> File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Lib\site-packages\PyInstaller\__main__.py", line 107, in run parser = generate_parser() ^^^^^^^^^^^^^^^^^ File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Lib\site-packages\PyInstaller\__main__.py", line 78, in generate_parser import PyInstaller.building.build_main ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Lib\site-packages\PyInstaller\building\build_main.py", line 35, in <module> from PyInstaller.depend import bindepend ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Lib\site-packages\PyInstaller\depend\bindepend.py", line 26, in <module> from PyInstaller.depend import dylib, utils ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Lib\site-packages\PyInstaller\depend\utils.py", line 33, in <module> from PyInstaller.depend import bytecode ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Lib\site-packages\PyInstaller\depend\bytecode.py", line 95, in <module> _call_function_bytecode = bytecode_regex(rb""" ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Lib\site-packages\PyInstaller\depend\bytecode.py", line 60, in bytecode_regex pattern = re.sub( ^^^^^^^ File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Lib\re.py", line 190, in sub return _compile(pattern, flags).sub(repl, string, count) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Lib\site-packages\PyInstaller\depend\bytecode.py", line 62, in <lambda> lambda m: _instruction_to_regex(m[1].decode()), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Lib\site-packages\PyInstaller\depend\bytecode.py", line 40, in _instruction_to_regex return re.escape(bytes([dis.opmap[x]])) ~~~~~~~~~^^^ KeyError: 'CALL_FUNCTION' I'm trying to create a single-file executable for Windows from a Python application, using pyinstaller, but the commend doesn't run and
I honestly do not know what that error is. All I can say is that
the command for making a single .exe file with pyinstaller is:
pyinstaller --onefile <filename>
For example pyinstaller --onefile myscript.py
I did a quick search and found this in pyinstaller: create one executable file
What you have done is pyinstaller onefile, which is the same as telling pyinstaller to create the executable using a file called onefile. When the program doesn't find the file 'onefile' it will not work, and it throws an error.
This was addressed here:
https://github.com/pyinstaller/pyinstaller/issues/6950
Looks like it's been merged in so make sure your PyInsaller version is 5.6 or greater.
I think you made a mistake when you writing arguments can you give more details? or if you can't use PyInsaller on shell you can use this library with pyinstaller gui https://pypi.org/project/auto-py-to-exe/
PyInstaller: 5.0.1
Python: 3.7.9
output: https://gist.github.com/phonebotco/eee157bd12a3b9f0792b2fcab9478636
I am trying to compilate my code with this command:
pyinstaller --onefile -F --uac-admin --icon="favicon_phonebot.ico" --exclude-module modname_tkinter --debug=all PhoneBot.py
I get this error message:
File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks\hook-IPython.py", line 16, in <module>
from PyInstaller.compat import modname_tkinter, is_win, is_darwin
ImportError: cannot import name 'modname_tkinter' from 'PyInstaller.compat' (c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\compat.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\gauth\appdata\local\programs\python\python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\gauth\appdata\local\programs\python\python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\gauth\AppData\Local\Programs\Python\Python37\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\__main__.py", line 178, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\__main__.py", line 59, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\building\build_main.py", line 845, in main
build(specfile, distpath, workpath, clean_build)
File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\building\build_main.py", line 767, in build
exec(code, spec_namespace)
File "H:\Mon Drive\Phonebot\Phonebot_debug3\PhoneBot.spec", line 20, in <module>
noarchive=False,
File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\building\build_main.py", line 319, in __init__
self.__postinit__()
File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\building\datastruct.py", line 173, in __postinit__
self.assemble()
File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\building\build_main.py", line 487, in assemble
self.graph.process_post_graph_hooks(self)
File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\depend\analysis.py", line 326, in process_post_graph_hooks
module_hook.post_graph(analysis)
File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\depend\imphook.py", line 398, in post_graph
self._load_hook_module()
File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\depend\imphook.py", line 364, in _load_hook_module
raise ImportErrorWhenRunningHook(self.hook_module_name, self.hook_filename)
PyInstaller.exceptions.ImportErrorWhenRunningHook: Failed to import module __PyInstaller_hooks_0_IPython required by hook for module c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks\hook-IPython.py. Please check whether module __PyInstaller_hooks_0_IPython actually exists and whether the hook is compatible with your version of c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks\hook-IPython.py: You might want to read more about hooks in the manual and provide a pull-request to improve PyInstaller.
H:\Mon Drive\Phonebot\Phonebot_debug3>pyinstaller --onefile -F --uac-admin --icon="favicon_phonebot.ico" --exclude-module modname_tkinter --debug=all PhoneBot.py
The weird thing is I don't use Tkinter in my code. Can anyone help me please fix this issue?
Thanks
I was using Pyinstaller version 5.1 and had similar error. After I downgraded Pyinstaller to version 4.5.1 the problem was solved.
pip install -U pyinstaller-hooks-contrib
I was using an outdated version of pyinstaller-hooks-contrib - the offending import line in that IPython hook has been removed over a year ago.
for me helped update kivy lib to the last version
I'm attempting to use Py2exe to create a Python executable out of my program. The program definitely works and I've made sure all the libraries it uses are up to date, but when I attempt to run the command "python setup.py py2exe" to finish it up, I get an error I'm unfamiliar with.
The full output is below:
running py2exe
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\site-packages\setuptools\distutils_patch.py:25: UserWarning: Distutils was imported before Setuptools. This usage is discouraged and may exhibit undesirable behaviors or errors. Please use Setuptools' objects directly or at least import Setuptools first.
warnings.warn(
Traceback (most recent call last):
File "C:\Users\user\OneDrive\Desktop\intern\pdf\setup.py", line 11, in
setup(console=[{ "script": "tca_script.py"}],
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\py2exe\distutils_buildexe.py", line 192, in run
self._run()
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\py2exe\distutils_buildexe.py", line 272, in _run
builder.analyze()
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\py2exe\runtime.py", line 172, in analyze
mf.import_package(modname)
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\py2exe\mf34.py", line 84, in import_package
self.import_package("%s.%s" % (name, modname))
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\py2exe\mf34.py", line 84, in import_package
self.import_package("%s.%s" % (name, modname))
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\py2exe\mf34.py", line 84, in import_package
self.import_package("%s.%s" % (name, modname))
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\py2exe\mf34.py", line 71, in import_package
package = self.modules[name]
KeyError: 'pandas.tests.io.excel'
Any help would be greatly appreciated.
I am new to python and attempting to setup up a mono repo using pants as the build system. All has been going well, until I told pants to use a python 3 interpreter by setting in pants.ini
[python-setup]
interpreter_constraints: ["CPython>=3.6.5"]
I have a setup a local library python_library which is imported into a python_binary.
In other words, for an identical code base,
running ./pants run ... on python 2.7 works perfectly
running ./pants run ... with the above interpreter_constraints fails with ModuleNotFoundError
The stack trace I am getting looks like
Traceback (most recent call last):
File "/home/daniel/PycharmProjects/analytics-platform/.pants.d/run/py/CPython-3.6.8/8c5d2b01b2fb9952ae4d6116e537a04edd7039e8/.bootstrap/pex/pex.py", line 397, in execute
exit_code = self._wrap_coverage(self._wrap_profiling, self._execute)
File "/home/daniel/PycharmProjects/analytics-platform/.pants.d/run/py/CPython-3.6.8/8c5d2b01b2fb9952ae4d6116e537a04edd7039e8/.bootstrap/pex/pex.py", line 329, in _wrap_coverage
return runner(*args)
File "/home/daniel/PycharmProjects/analytics-platform/.pants.d/run/py/CPython-3.6.8/8c5d2b01b2fb9952ae4d6116e537a04edd7039e8/.bootstrap/pex/pex.py", line 360, in _wrap_profiling
return runner(*args)
File "/home/daniel/PycharmProjects/analytics-platform/.pants.d/run/py/CPython-3.6.8/8c5d2b01b2fb9952ae4d6116e537a04edd7039e8/.bootstrap/pex/pex.py", line 442, in _execute
return self.execute_entry(self._pex_info.entry_point)
File "/home/daniel/PycharmProjects/analytics-platform/.pants.d/run/py/CPython-3.6.8/8c5d2b01b2fb9952ae4d6116e537a04edd7039e8/.bootstrap/pex/pex.py", line 540, in execute_entry
return runner(entry_point)
File "/home/daniel/PycharmProjects/analytics-platform/.pants.d/run/py/CPython-3.6.8/8c5d2b01b2fb9952ae4d6116e537a04edd7039e8/.bootstrap/pex/pex.py", line 547, in execute_module
runpy.run_module(module_name, run_name='__main__')
File "/usr/lib/python3.6/runpy.py", line 208, in run_module
return _run_code(code, {}, init_globals, run_name, mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/daniel/PycharmProjects/analytics-platform/.pants.d/pyprep/sources/b9e34cbd28ac4d65dc0c5e39ad35ba34da17a128/src/main.py", line 1, in <module>
from str_utils import normalize
ModuleNotFoundError: No module named 'str_utils'
Is there anything I need to add to the pants.ini file when using CPython>=3.6.5?
Please note - the code used works on python2 and python3 when executed manually
I have a .py file that creates a GUI, which runs another script once I give it some information. I'm trying to make a .exe file from this GUI file using py2exe, but I've been having trouble.
Exception: Seems not to be an exe-file
If anyone who has experience with py2exe and has encountered this message before, could you explain to me why it's not working, and what I could do to fix it? Thanks in advance.
EDIT: My setup.py looks like this:
from distutils.core import setup
import py2exe
setup(console=['test_gui.py'])
I run this code through the command prompt like this:
python setup.py py2exe
And the traceback is as follows:
Traceback (most recent call last):
File "setup.py", line 4, in <module>
setup(console=['test_gui.py'])
File "C:\Python26\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "C:\Python26\lib\distutils\dist.py", line 975, in run_commands
self.run_command(cmd)
File "C:\Python26\lib\distutils\dist.py", line 995, in run_command
cmd_obj.run()
File "C:\Python26\Lib\site-packages\py2exe\build_exe.py", line 243, in run
self._run()
File "C:\Python26\Lib\site-packages\py2exe\build_exe.py", line 305, in _run
dlls = self.find_dlls(extensions)
File "C:\Python26\Lib\site-packages\py2exe\build_exe.py", line 389, in find_dlls
self.dll_excludes)
File "C:\Python26\Lib\site-packages\py2exe\build_exe.py", line 1064, in find_d
ependend_dlls
bin_depends(loadpath, images + [sys.executable], excludes_use)
File "C:\Python26\Lib\site-packages\py2exe\build_exe.py", line 1441, in bin_de
pends
if isSystemDLL(dll):
File "C:\Python26\Lib\site-packages\py2exe\build_exe.py", line 1498, in isSyst
emDLL
raise Exception, "Seems not to be an exe-file"
Exception: Seems not to be an exe-file