I have Python 3.8 on a windows 10 64bit. I had some trouble installing cx-Freeze and had to install "cx_Freeze-6.0-cp38-cp38-win32.whl", as it was the only one that worked.
I am trying to convert a script that generates a simple GUI using wxPyhton to an executable.
I get the following error when i run "steup.py build"
running build
running build_exe
.....
copying C:\Users\ptanas\AppData\Local\Programs\Python\Python38-32\VCRUNTIME140.dll -> build\exe.win32-3.8\VCRUNTIME140.dll
Traceback (most recent call last):
File "setup.py", line 21, in <module>
setup(name='editor',
File "C:\Users\ptanas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\cx_Freeze\dist.py", line 348, in setup
distutils.core.setup(**attrs)
File "C:\Users\ptanas\AppData\Local\Programs\Python\Python38-32\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\ptanas\AppData\Local\Programs\Python\Python38-32\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\Users\ptanas\AppData\Local\Programs\Python\Python38-32\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\ptanas\AppData\Local\Programs\Python\Python38-32\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "C:\Users\ptanas\AppData\Local\Programs\Python\Python38-32\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\ptanas\AppData\Local\Programs\Python\Python38-32\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\ptanas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\cx_Freeze\dist.py", line 219, in run
freezer.Freeze()
File "C:\Users\ptanas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\cx_Freeze\freezer.py", line 617, in Freeze
self._FreezeExecutable(executable)
File "C:\Users\ptanas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\cx_Freeze\freezer.py", line 208, in _FreezeExecutable
self._AddVersionResource(exe)
File "C:\Users\ptanas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\cx_Freeze\freezer.py", line 143, in _AddVersionResource
stamp(fileName, versionInfo)
File "C:\Users\ptanas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\win32\lib\win32verstamp.py", line 157, in stamp
vs = VS_VERSION_INFO(vmaj, vmin, vsub, vbuild, sdata, vdata, is_debug, is_dll)
File "C:\Users\ptanas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\win32\lib\win32verstamp.py", line 103, in VS_VERSION_INFO
result = result + nullterm('VS_VERSION_INFO')
File "C:\Users\ptanas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\win32\lib\win32verstamp.py", line 50, in nullterm
return (str(s) + '\0').encode('unicode-internal')
LookupError: unknown encoding: unicode-internal
I have no idea why this error appears.
setup.py:
import os
import sys
from cx_Freeze import Executable, setup
# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(
packages = [],
excludes = [],
include_files=[]
)
base = 'Win32GUI' if sys.platform=='win32' else None
executables = [
Executable('test.py', base=base)
]
setup(name='editor',
version = '1.0',
description = '',
options = dict(build_exe = buildOptions),
executables = executables)
It's fixed: https://github.com/mhammond/pywin32/commit/74f9d8b8b549ff0d547ff600eaca1f25c79b4432.
Upgrade pywin32:
pip install -U pywin32
Related
python setup.py py2exe
The following error occurred while using py2exe.
The source code for setup.py:
# setup.py
from distutils.core import setup
import py2exe
setup(console=['python.py'])
I'm trying to make python.py exe.
the mistake of this moment:
E:\ajil\Program\Query>python setup.py py2exe
running py2exe
Traceback (most recent call last):
File "setup.py", line 4, in <module>
setup(console=['python.py'])
File "C:\Users\dashzeveg.b\AppData\Local\Programs\Python\Python37\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\dashzeveg.b\AppData\Local\Programs\Python\Python37\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\Users\dashzeveg.b\AppData\Local\Programs\Python\Python37\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\dashzeveg.b\AppData\Local\Programs\Python\Python37\lib\site-packages\py2exe\distutils_buildexe.py", line 188, in run
self._run()
File "C:\Users\dashzeveg.b\AppData\Local\Programs\Python\Python37\lib\site-packages\py2exe\distutils_buildexe.py", line 267, in _run
builder.analyze()
File "C:\Users\dashzeveg.b\AppData\Local\Programs\Python\Python37\lib\site-packages\py2exe\runtime.py", line 160, in analyze
self.mf.import_hook(modname)
File "C:\Users\dashzeveg.b\AppData\Local\Programs\Python\Python37\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Users\dashzeveg.b\AppData\Local\Programs\Python\Python37\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Users\dashzeveg.b\AppData\Local\Programs\Python\Python37\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load
self._scan_code(module.__code__, module)
File "C:\Users\dashzeveg.b\AppData\Local\Programs\Python\Python37\lib\site-packages\py2exe\mf3.py", line 388, in _scan_code
for what, args in self._scan_opcodes(code):
File "C:\Users\dashzeveg.b\AppData\Local\Programs\Python\Python37\lib\site-packages\py2exe\mf3.py", line 417, in _scan_opcodes
yield "store", (names[oparg],)
IndexError: tuple index out of range
Use Pyinstaller that will help you for this. pyinstaller
pip install PyInstaller
pyinstaller <options> <ScriptName.py>
pyinstaller myscript.py # Normal Usage
pyinstaller --onefile myscript.py # To create single executable
I am unable to turn a game I made from a tutorial on youtube into an executable with cx_Freeze. I'm using virtualenv and cx_Freeze is version 5.0. When running the game I get a message:
Fatal Python error: Py_Initialize: unable to load the file system codec
ImportError: No module named 'encodings'
Current thread 0x00002c24 (most recent call first):
Below is the trace backs when creating the file.
(pygame) G:\Programming\scripts\Python\PyGame\compile_files>python setup.py build
running build
running build_exe
creating directory build\exe.win32-3.5
copying G:\Programming\scripts\Python\virtualenv\pygame\lib\site-packages\cx_Freeze\bases\Console.exe -> build\exe.win32-3.5\Slither.exe
copying G:\Programming\scripts\Python\virtualenv\pygame\Scripts\python35.dll -> build\exe.win32-3.5\python35.dll
Traceback (most recent call last):
File "setup.py", line 12, in <module>
executables=executables
File "G:\Programming\scripts\Python\virtualenv\pygame\lib\site-packages\cx_Freeze\dist.py", line 349, in setup
distutils.core.setup(**attrs)
File "G:\python\Python35-32\Lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "G:\python\Python35-32\Lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "G:\python\Python35-32\Lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "G:\python\Python35-32\Lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "G:\python\Python35-32\Lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "G:\python\Python35-32\Lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "G:\Programming\scripts\Python\virtualenv\pygame\lib\site-packages\cx_Freeze\dist.py", line 219, in run
freezer.Freeze()
File "G:\Programming\scripts\Python\virtualenv\pygame\lib\site-packages\cx_Freeze\freezer.py", line 623, in Freeze
self._FreezeExecutable(executable)
File "G:\Programming\scripts\Python\virtualenv\pygame\lib\site-packages\cx_Freeze\freezer.py", line 225, in _FreezeExecutable
self._AddVersionResource(exe)
File "G:\Programming\scripts\Python\virtualenv\pygame\lib\site-packages\cx_Freeze\freezer.py", line 165, in _AddVersionResource
trademarks = exe.trademarks)
File "G:\Programming\scripts\Python\virtualenv\pygame\lib\site-packages\cx_Freeze\freezer.py", line 759, in __init__
parts = version.split(".")
AttributeError: 'NoneType' object has no attribute 'split'
(pygame) G:\Programming\scripts\Python\PyGame\compile_files>`
My setup file is:
import cx_Freeze
import os
os.environ['TCL_LIBRARY'] = "G:\\python\\Python35-32\\tcl\\tcl8.6"
os.environ['TK_LIBRARY'] = "G:\\python\\Python35-32\\tcl\\tk8.6"
executables=[cx_Freeze.Executable("Game.py")]
cx_Freeze.setup(
name="Game",
options={"build_exe":{"packages":["pygame"],"include_files":["image1.png","image2.png"]}},
description="Game",
executables=executables
)
The images are in the same directory as the setup.py file.
Use this in your setup file:
from cx_Freeze import setup,Executable
setup(name="NAME OF YOUR PROGRAM",
version="1.0",
description="as above",
executables=[Executable("NAME OF THE SCRIPT.py")])
After that, drag your png files to the folder into the same folder with your program.
python setup.py build
Finally put your png,jpg etc. files into that folder.
I'm trying to convert a python 3.4 program of mine into an exe for distribution. I tried using cx_Freeze to do this. However, when I run python setup.py build with this setup.py:
from cx_Freeze import setup, Executable
setup( name = "Converter" ,
version = "0.1" ,
description = "" ,
executables = [Executable("filename.py")] , )
I get this error code:
C:\Python34>python setup.py build
running build
running build_exe
Traceback (most recent call last):
File "setup.py", line 6, in <module>
executables = [Executable("helloworld.py")] , )
File "C:\Python34\lib\site-packages\cx_Freeze\dist.py", line 362, in setup
distutils.core.setup(**attrs)
File "C:\Python34\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Python34\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Python34\lib\distutils\command\build.py", line 126, in run
self.run_command(cmd_name)
File "C:\Python34\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Python34\lib\site-packages\cx_Freeze\dist.py", line 231, in run
metadata = metadata)
File "C:\Python34\lib\site-packages\cx_Freeze\freezer.py", line 136, in __init__
self._VerifyConfiguration()
File "C:\Python34\lib\site-packages\cx_Freeze\freezer.py", line 504, in _VerifyConfiguration
self._GetBaseFileName()
File "C:\Python34\lib\site-packages\cx_Freeze\freezer.py", line 239, in _GetBaseFileName
raise ConfigError("no base named %s", name)
cx_Freeze.freezer.ConfigError: no base named Console
This same error code occurs when I try to setup for a hello world file. So it has nothing to do with my script.
Any help? This is the first time I've used cx_Freeze.
It appears that this line is failing argsSource.base = self._GetFileName("bases", name, ext) which means that it can't find that file, which makes sense. Check this folder C:\Python27\Lib\site-packages\cx_Freeze\bases for Console.exe. If you don't have that then try reinstalling cx_freeze. That's my directory for python. I would assume yours is in the same place but if not just search for it
Just type in cmd "pip uninstall cx_Freeze" for uninstall cx_Freeze and again reinstall it by type "pip install cx_Freeze".
First I've no experience with python. I just want to install a module in blender which comes with a setup.py. It seems that I need Cython to install that. I added Cython to PYTHONPATH and the bin folder to the PATH. This error is shown:
python setup.py install
running install
running build
running build_ext
Traceback (most recent call last):
File "setup.py", line 17, in <module>
cmdclass = {'build_ext': build_ext})
File "C:\Python33\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Python33\lib\distutils\dist.py", line 917, in run_commands
self.run_command(cmd)
File "C:\Python33\lib\distutils\dist.py", line 936, in run_command
cmd_obj.run()
File "C:\Python33\lib\distutils\command\install.py", line 569, in run
self.run_command('build')
File "C:\Python33\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Python33\lib\distutils\dist.py", line 936, in run_command
cmd_obj.run()
File "C:\Python33\lib\distutils\command\build.py", line 126, in run
self.run_command(cmd_name)
File "C:\Python33\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Python33\lib\distutils\dist.py", line 936, in run_command
cmd_obj.run()
File "C:\Cython-0.19.1\Cython\Distutils\build_ext.py", line 163, in run
_build_ext.build_ext.run(self)
File "C:\Python33\lib\distutils\command\build_ext.py", line 354, in run
self.build_extensions()
File "C:\Cython-0.19.1\Cython\Distutils\build_ext.py", line 170, in build_extensions
ext.sources = self.cython_sources(ext.sources, ext)
File "C:\Cython-0.19.1\Cython\Distutils\build_ext.py", line 181, in cython_sources
from Cython.Compiler.Main \
File "C:\Cython-0.19.1\Cython\Compiler\Main.py", line 302
except UnicodeDecodeError#, e:
^
SyntaxError: invalid syntax
Versions are: Python 3.3 / Windows7 64 / Cython-0.19.1
Any ideas, what should I try?
It looks like your Cython installation was damaged somehow. You might want to consider getting a fresh installation, perhaps from the Cython Windows installer for Python 3.3.
I have been trying to get cx_freeze working on ubuntu, but when i try to run the "python setup.py build" i get the following error:
cx_Freeze.freezer.ConfigError: no initscript named Console
I have searched google and i see a lot of people have ahd this issue, but i can't seem to find a solution.
my setup.py code is as follows:
from cx_Freeze import setup, Executable
setup( name = "hello world" ,
version = "0.1" ,
description = "Hello" ,
executables = [Executable("hello.py")] ,
)
I have placed the setup.py file and hello.py in the same folder.
Any idea as to what could solve this problem?
running build
running build_exe
Traceback (most recent call last):
File "setup.py", line 7, in <module>
executables = [Executable("hello.py")] ,
File "/usr/local/lib/python2.7/dist-packages/cx_Freeze-4.3.1-py2.7-linux-i686.egg
cx_Freeze/dist.py", line 365, in setup
distutils.core.setup(**attrs)
File "/usr/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib/python2.7/distutils/command/build.py", line 128, in run
self.run_command(cmd_name)
File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/local/lib/python2.7/dist-packages/cx_Freeze-4.3.1-py2.7-linux-i686.egg
/cx_Freeze/dist.py", line 234, in run
metadata = metadata)
File "/usr/local/lib/python2.7/dist-packages/cx_Freeze-4.3.1-py2.7-linux-i686.egg
/cx_Freeze/freezer.py", line 104, in __init__
self._VerifyConfiguration()
File "/usr/local/lib/python2.7/dist-packages/cx_Freeze-4.3.1-py2.7-linux-i686.egg
/cx_Freeze/freezer.py", line 466, in _VerifyConfiguration
self._GetInitScriptFileName()
File "/usr/local/lib/python2.7/dist-packages/cx_Freeze-4.3.1-py2.7-linux-i686.egg
/cx_Freeze/freezer.py", line 311, in _GetInitScriptFileName
raise ConfigError("no initscript named %s", name)
cx_Freeze.freezer.ConfigError: no initscript named Console
For my installation I took same problem. Looks like symbolic link for initscripts not created, so I make it manually and everything works (change cx_Freeze version to your own):
cd /usr/local/lib/python2.7/dist-packages/
cd cx_Freeze-4.3.1-py2.7-linux-i686.egg
sudo ln -s -t cx_Freeze/ ../../cx_Freeze/initscripts/
PS: Ubuntu 12.10/quantal, Python 2.7.3