I created a executable with py2exe for a wxpython app what working fine, when starting the executable created gives me an error about os.popen. code that creates the executable is:
# setup.py
from distutils.core import setup
import py2exe
setup(name="GridSimple",scripts=["GridSimple.py"],)
http://i.stack.imgur.com/u9Sj8.jpg
Here about this problem http://wiki.wxpython.org/CreatingStandaloneExecutables?highlight=%28unicows.dll%29#py2exe
They say "include the file unicows.dll" Where is it?
Related
I`m trying to make an executable from my python script called ProyectoNew.py. It works with a folder called "Imagenes" and another called "ModulosExternos", and a PyQT5's .ui file like this:
Here`s the Code posted in GitHub: https://github.com/TheFlosh/ProyectoSoftware.git
I`ve tried to use Pyinstaller, Py2Exe and CXFreeze but it didn't worked. Using each one of these modules to create a .exe file I've got the same result when I tried to execute it in another PC, as shown here:
On the LEFT of the picture you can see what I get after using pyinstaller (or Py2Exe), on the right you can see what I need to show.
Here are the modules that I use in my code ("ModulosExternos" is the folder where I put some particular modules that my code needs):
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
import pyttsx3
from pyttsx3.drivers import sapi5
import PyQt5
import sip
import os
from ModulosExternos import Boton_1,Boton_2,Boton_3,Boton_4,Boton_Final,Listas_Pictogramas, Frases_Completas
And here is the last part of it, to instantiate the GUI:
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
GUI = ProyectoNew()
GUI.show()
sys.exit(app.exec())
I`ve read a lot of posts on the internet that recommended creating Setup.Py file to initiate the process of creating an executable file of my project. These are some examples of what I did with two of them:
With CX_Freeze:
import sys
import os
from cx_Freeze import setup, Executable
files = ['icono.ico','/Imagenes']
target = Executable(
script = "/ProyectoNew.py",
base = 'Win32GUI',
)
#Setup
setup(
name = "Proyect2",
version = "1.6",
description = "Software",
author = "----",
options = {'build_exe': {'include_files' : files}},
executables = [target]
)
With Py2Exe:
from cx_Freeze import setup, Executable
setup(name = "Proyect2",
version="1.0",
description = "Software",
executables = [Executable("ProyectoNew.py")],)
With Pyinstaller I typed: python --nowindowed --onefile ProyectoNew.py but I constantly got the same result as shown before.
I think that when I execute Pyinstaller, the .exe file doesn`t load the modules and the images that I use. What am I missing while creating the file? What do I need to do to execute the .exe file in another PC?.
I would prefer to use pyinstaller,but using any one of these will help me.
What's is wrong with that? You get some kind of error? Please edit your question with that.
With pyinstaller and this command, you should be able easily build an executable file:
pyinstaller [FILE].py -w -F
This command generate a /dist folder with the neccesary files and .exe file to run
*-w param is for do not provide a console window for standard i/o
*-F param is for one-file bundled executable
You can check more params here
PD: Before, you need obviously install pyinstaller:
pip install pyinstaller
I've got a command line program that uses Python's click package. I can install and run it locally, no problem with:
pip install --editable . # (or leave out the editable of course)
Now, I'd like to create an executable file that can be distributed and run standalone. Typically, since I'm in a Windows environment, I would use one of py2exe, pyinstaller or cx_Freeze. However, none of these packages work.
More specifically, they all generate an executable, but the executable does nothing. I suspect this problem is because my main.py script doesn't have a main function. Any suggestions would be very helpful, thanks in advance!
Can reproduce the issues with code copied from here.
hello.py
import click
#click.command()
def cli():
click.echo("I AM WORKING")
setup.py
from distutils.core import setup
import py2exe
setup(
name="hello",
version="0.1",
py_modules=['hello'],
install_requires=[
'Click'
],
entry_points="""
[console_scripts]
hello=hello:cli
""",
console=['hello.py']
)
If someone could supply a working setup.py file to create an executable and any other required files, that would be much appreciated.
From the console:
python setup.py py2exe
# A bunch of info, no errors
cd dist
hello.exe
# no output, should output "I AM WORKING"
I much prefer pyinstaller to the other alternatives, so I will cast an answer in terms of pyinstaller.
Starting click app when frozen
You can detect when your program has been frozen with pyinstaller, and then start the click app like:
if getattr(sys, 'frozen', False):
cli(sys.argv[1:])
Building an exe with pyinstaller
This simple test app can be built simply with:
pyinstaller --onefile hello.py
Test Code:
import sys
import click
#click.command()
#click.argument('arg')
def cli(arg):
click.echo("I AM WORKING (%s)" % arg)
if getattr(sys, 'frozen', False):
cli(sys.argv[1:])
Testing:
>dist\test.exe an_arg
I AM WORKING (an_arg)
I am trying to do something, which given Python's prevalence, should be easy: convert my .py script into a Windows .exe file.
I have spent countless hours with pyinstaller and p2exe, but they don't work for me. Therefore I am trying to use cx_Freeze. My script is called sebzo.py and associated with it, in the folder wavFiles, are several .wav files.
I downloaded cx_Freeze by using Anaconda and the command:
conda install -c pyzo cx_freeze=5.0 to re-download cx_Freeze. cx_Freeze and related files ended up in c: Users\Owen Walker\Lib\site-packages.
Then I wrote a setup.py file as advised by various websites and placed sebzo.py, setup.py, and the subfolder wavFiles--in the folder: Users\Owen Walker\Lib\site-packages.
Then on the Windows 10 command line, in c: Users\Owen Walker\Lib\site-packages, I entered the command: "python setup.py build", and got the error: "File "setup.py", line 2 in from cx_Freeze import setup, Executable ImportError: cannot import name 'setup'"
The setup.py file reads:
import sys
from cx_Freeze import setup, Executable
setup(
name = "sebzo",
version = "0.1",
description = "arithmetic practice program",
executables = [Executable("sebzo.py")],
)
I don't know what the error means or how to fix it.
I coded a python application with a GUI in Tkinter with pictures. Now that I have finished, I am trying to convert it to a .exe with py2exe. All my pictures are in the same folder as my python file and setup file, but when I try to convert my python file via the Command Prompt, I get error messages saying that my .ico file is not defined and that it can not copy it. I think the problem is due to my setup.py file. How do I allow my images to be copied into the new .exe executable file without getting errors I have never used py2exe before.
Setup file:
from distutils.core import setup
import py2exe
setup(console=['Gui.py'])
Error:
How do I fix this?
You may have just forgotten to define your icon:
cfg = {
'py2exe.icon':'icon.ico',
...
}
Try to change your setup.py like this:
from distutils.core import setup
import py2exe
data_files = [('', [r'standardicon.ico'])]
setup(
windows =['Gui.py'],
data_files = data_files
)
I need to use my python program on many different computers with Windows XP and 7, without having to download a Python interpreter. So I create *.exe with py2exe. But when I start it on XP without python installed, I'm getting an error message: «file is corrupt». Is there any way to start it on XP without python?
Here's my setup.py:
from distutils.core import setup
import py2exe
setup(
windows=[{"script":"linksender.py"}],
options={"py2exe": {"includes":[]}}
)
1.Check your distutils.core.It exist or not.Are you copying the setup.py from the internet?If so ,Copy distutils.core also.
2.Try this(script name=myscript.py):
# setup.py
from distutils.core import setup
import py2exe
setup(console=["myscript.py"])
3.Your distutils should be something like this:
#!/usr/bin/env python
from distutils.core import setup
setup(name='Distutils',
version='1.0',
description='Python Distribution Utilities',
author='Greg Ward',
author_email='gward#python.net',
url='http://www.python.org/sigs/distutils-sig/',
packages=['distutils', 'distutils.command'],
)
Note:I am not an expert I have used it once before and it worked for me.