I am trying to make a cx_Freeze gui in python 3.
When I type pyton setup.py build
I get this error :
running build
running build_exe
Traceback (most recent call last):
File "setup.py", line 356, in <module>
executables=executables
File "C:\Program Files (x86)\lib\site-packages\cx_Freeze\dist.py",
n setup
distutils.core.setup(**attrs)
File "C:\Program Files (x86)\lib\distutils\core.py", line 148, in s
dist.run_commands()
File "C:\Program Files (x86)\lib\distutils\dist.py", line 955, in r
self.run_command(cmd)
File "C:\Program Files (x86)\lib\distutils\dist.py", line 974, in r
cmd_obj.run()
File "C:\Program Files (x86)\lib\distutils\command\build.py", line
self.run_command(cmd_name)
File "C:\Program Files (x86)\lib\distutils\cmd.py", line 313, in ru
self.distribution.run_command(command)
File "C:\Program Files (x86)\lib\distutils\dist.py", line 974, in r
cmd_obj.run()
File "C:\Program Files (x86)\lib\site-packages\cx_Freeze\dist.py",
n run
zipExcludePackages = self.zip_exclude_packages)
File "C:\Program Files (x86)\lib\site-packages\cx_Freeze\freezer.py
, in __init__
self._VerifyConfiguration()
File "C:\Program Files (x86)\lib\site-packages\cx_Freeze\freezer.py
, in _VerifyConfiguration
executable._VerifyConfiguration(self)
AttributeError: 'str' object has no attribute '_VerifyConfiguration'
My code is to long to be copied here but it is in two parts
The tkinter class (the 'long' part)
The simple cx_Freeze script
EDIT
The line where the error is is the last line of the setup function:
setup(
name=inter.name,
version=inter.version,
description=inter.description,
author=inter.author,
options={"build_exe": options},
executables=executables
)
Related
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
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 working with Py2exe to generate an executable in Python(anaconda 3) and it gives me this error.
running py2exe
Error: Namespace packages not yet supported: Skipping package 'win32com.gen_py'
Traceback (most recent call last):
File "setup.py", line 32, in <module>
**kwargs)
File "C:\Program Files\Anaconda3\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Program Files\Anaconda3\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Program Files\Anaconda3\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
...
File "C:\Program Files\Anaconda3\lib\site-packages\py2exe\mf3.py", line 261, in _gcd_import
name = self._resolve_name(name, package, level)
File "C:\Program Files\Anaconda3\lib\site-packages\py2exe\mf3.py", line 213, in _resolve_name
raise ValueError('attempted relative import beyond top-level package')
ValueError: attempted relative import beyond top-level package
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 use py2app to create a standalone application of mac. When I`m using the alias mode everything work fine, but when I try to
python setup.py py2app
I receive this error:
Traceback (most recent call last):
File "setup.py", line 21, in <module>
setup_requires=['py2app'],
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/Users/robert/Envs/py36/lib/python3.6/site-packages/py2app/build_app.py", line 659, in run
self._run()
File "/Users/robert/Envs/py36/lib/python3.6/site-packages/py2app/build_app.py", line 865, in _run
self.run_normal()
File "/Users/robert/Envs/py36/lib/python3.6/site-packages/py2app/build_app.py", line 943, in run_normal
self.process_recipes(mf, filters, flatpackages, loader_files)
File "/Users/robert/Envs/py36/lib/python3.6/site-packages/py2app/build_app.py", line 824, in process_recipes
rval = check(self, mf)
File "/Users/robert/Envs/py36/lib/python3.6/site-packages/py2app/recipes/virtualenv.py", line 86, in check
mf._scan_code(co, m)
File "/Users/robert/Envs/py36/lib/python3.6/site-packages/modulegraph/modulegraph.py", line 1543, in _scan_code
self._scan_bytecode(co, m)
File "/Users/robert/Envs/py36/lib/python3.6/site-packages/modulegraph/modulegraph.py", line 1570, in _scan_bytecode
n = len(code)
NameError: name 'code' is not defined
My version of Python 3.5, py2app 0.10, module graph 0.13. Has anyone encountered a similar one, and how I can solve it?
P.S. Sorry for my bad English.
I had the same issue.
This issue will be fixed in moudulegraph 0.14
If you can't wait you can pull from the repo any point after this commit:
https://bitbucket.org/ronaldoussoren/modulegraph/commits/32c6c60f9dcdb106219a1476218e0d364cb11255