When I try to build my game compiler I get error:
Traceback (most recent call last):
File "gamecomp.py", line 22, in <module>
executables = [exe])
File "C:\Python33\lib\site-packages\cx_Freeze\dist.py", line 365, in setup
distutils.core.setup(**attrs)
File "C:\Python33\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Python33\lib\distutils\dist.py", line 929, in run_commands
self.run_command(cmd)
File "C:\Python33\lib\distutils\dist.py", line 948, 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 948, in run_command
cmd_obj.run()
File "C:\Python33\lib\site-packages\cx_Freeze\dist.py", line 234, in run
metadata = metadata)
File "C:\Python33\lib\site-packages\cx_Freeze\freezer.py", line 104, in __init
__
self.includeFiles = self._ProcessPathSpecs(includeFiles)
File "C:\Python33\lib\site-packages\cx_Freeze\freezer.py", line 384, in _Proce
ssPathSpecs
raise ConfigError("target path for include file may not be "
cx_Freeze.freezer.ConfigError: target path for include file may not be an absolu
te path
My compiler is:
import sys
from cx_Freeze import setup, Executable
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"], "include_files":["C:\Documents and Settings\boot_1.bmp", "C:\Documents and Settings\boot_2.bmp", 'C:\Documents and Settings\boot_3.bmp', 'C:\Documents and Settings\boot_4.bmp', 'C:\Documents and Settings\fish1.bmp', 'C:\Documents and Settings\fish2.bmp', 'C:\Documents and Settings\fish3.bmp', 'C:\Documents and Settings\fish4.bmp', 'C:\Documents and Settings\goldenfish_1.bmp', 'C:\Documents and Settings\goldenfish_2.bmp']}
base = None
if sys.platform == "win32":
base = "Win32GUI"
exe=Executable(
script="game.py",
base=base
)
setup( name = "Game name",
version = "1.0",
description = "My GUI application!",
options = {"build_exe": build_exe_options},
executables = [exe])
If I don't use include_files I can compile the game without any errors, but others can't play the game.
How can I compile my game without errors / fix errors?
I get it now.
I have to write: "boot_1.bmp" instead "C:\Documents and Settings\boot_1.bmp" and so for all other pictures.
I also have to change it in the game code.
Related
I have already create an issue in github. But no one reply.
The question is:
I runpython3 setup.py py2app and the error:
Traceback (most recent call last):
File "/Users/th/source/duomai/send_email.py/setup.py", line 14, in <module>
setup(
File "/usr/local/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/usr/local/Cellar/python#3.9/3.9.0_5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/local/Cellar/python#3.9/3.9.0_5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/usr/local/Cellar/python#3.9/3.9.0_5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/usr/local/lib/python3.9/site-packages/py2app/build_app.py", line 925, in run
self._run()
File "/usr/local/lib/python3.9/site-packages/py2app/build_app.py", line 1147, in _run
self.run_normal()
File "/usr/local/lib/python3.9/site-packages/py2app/build_app.py", line 1244, in run_normal
self.process_recipes(mf, filters, flatpackages, loader_files)
File "/usr/local/lib/python3.9/site-packages/py2app/build_app.py", line 1099, in process_recipes
rval = check(self, mf)
File "/usr/local/lib/python3.9/site-packages/py2app/recipes/sip.py", line 111, in check
mf.import_hook("sip", m)
File "/usr/local/lib/python3.9/site-packages/modulegraph/modulegraph.py", line 1114, in import_hook
q, tail = self._find_head_package(parent, name, level)
File "/usr/local/lib/python3.9/site-packages/modulegraph/modulegraph.py", line 1215, in _find_head_package
raise ImportError("No module named " + qname)
ImportError: No module named sip
And my setup.py
"""
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
"""
from setuptools import setup
APP = ['cli.py']
DATA_FILES = []
OPTIONS = {}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
It's seems like qt relative. But I didn't used qt, I just use the tkinter...
The detail log is long, I create an attach. https://www.dropbox.com/s/4pcc9zv7dgoq37j/log.txt?dl=0
How to fix this?
Try adding the packages to your options in the setup file, like this:
OPTIONS = {
'argv_emulation': True,
'packages':['tkinter']}
I'm trying to compile python script to exe.
My script - hello.py:
print("hello")
My setup.py:
from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')
setup(
name = 'hello',
description = 'hello script',
version = '1.0',
options = {'py2exe': {'bundle_files': 1, 'compressed': True,'dist_dir': ".",'dll_excludes':['w9xpopen.exe']}},
console = [{'script': r"hello.py"}],
zipfile = None,
)
I run:
py -3 setup.py install
The error:
py -3 setup.py install
running install
running build
running install_egg_info
Removing C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\hello-1.0-py3.7.egg-info
Writing C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\hello-1.0-py3.7.egg-info
running py2exe
Traceback (most recent call last):
File "setup.py", line 19, in <module>
zipfile = None,
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py2exe\distutils_buildexe.py", line 188, in run
self._run()
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py2exe\distutils_buildexe.py", line 267, in _run
builder.analyze()
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py2exe\runtime.py", line 160, in analyze
self.mf.import_hook(modname)
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load
self._scan_code(module.__code__, module)
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py2exe\mf3.py", line 388, in _scan_code
for what, args in self._scan_opcodes(code):
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py2exe\mf3.py", line 417, in _scan_opcodes
yield "store", (names[oparg],)
IndexError: tuple index out of range
Do you know how to resolve this error?
py2exe seems to support up to Python 3.4 (thanks Michael Butscher)
However, there are other libraries such as Pyinstaller which work just fine, and are compatible with a variety of Python versions (from Python 2.7 to 3.5+)
Check it out, it's actually really easy :)
https://pyinstaller.readthedocs.io/en/stable/
I want to build_ext a ".pyd" file but it didn't work.
I tried to update visual, update compilers etc .. nothing worked ...
I want to use this command:
python setup.py build_ext --inplace --compiler=cygwin
with setup.py:
from distutils.core import setup
from Cython.Build import cythonize
import os
os.environ["CC"] = "gcc-5.3.0"
os.environ["CXX"] = "gcc-5.3.0"
directives = {'linetrace': False, 'language_level': 3}
setup(ext_modules = cythonize('local_correlation.cp37-win_amd64.pyd'))
and i have it :
running build_ext
Traceback (most recent call last):
File "setup.py", line 15, in <module>
setup(ext_modules = cythonize('local_correlation.cp37-win_amd64.pyd'))
File "C:\Users\benfr\Anaconda3\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\benfr\Anaconda3\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\Users\benfr\Anaconda3\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\benfr\Anaconda3\lib\distutils\command\build_ext.py", line 308, in run
force=self.force)
File "C:\Users\benfr\Anaconda3\lib\distutils\ccompiler.py", line 1031, in new_compiler
return klass(None, dry_run, force)
File "C:\Users\benfr\Anaconda3\lib\distutils\cygwinccompiler.py", line 137, in __init__
if self.ld_version >= "2.10.90":
TypeError: '>=' not supported between instances of 'NoneType' and 'str'
I am very new to cx_freeze and I am trying to understand it a bit better, I have this setup.py file:
import sys
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"]}
setup( name = "guifoo",
version = "0.1",
description = "My GUI application!",
options = {"build_exe": build_exe_options},
executables = [Executable("mypy.py", base="Console", targetName="hello")])
which if I remove the targetName="hello" it works however when I include it, it doesnt. Would anyone know why?
This is my python code:
# encoding: utf8
import math
print "Starting..."
print math.sqrt(16)
input("please press enter to exit...")
After running python setup.py build I get the following errors:
running build
running build_exe
creating directory build\exe.win32-2.7
copying C:\Python27\lib\site-packages\cx_Freeze\bases\Console.exe -> build\exe.win32-2.7\hello
copying C:\Windows\system32\python27.dll -> build\exe.win32-2.7\python27.dll
Traceback (most recent call last):
File "setup.py", line 11, in <module>
executables = [Executable("mypy.py", base="Console", targetName="hello")])
File "C:\Python27\lib\site-packages\cx_Freeze\dist.py", line 362, in setup
distutils.core.setup(**attrs)
File "C:\Python27\lib\distutils\core.py", line 151, in setup
dist.run_commands()
File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd)
File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\Python27\lib\distutils\command\build.py", line 127, in run
self.run_command(cmd_name)
File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\Python27\lib\site-packages\cx_Freeze\dist.py", line 232, in run
freezer.Freeze()
File "C:\Python27\lib\site-packages\cx_Freeze\freezer.py", line 621, in Freeze
self._FreezeExecutable(executable)
File "C:\Python27\lib\site-packages\cx_Freeze\freezer.py", line 211, in _FreezeExecutable
self._AddVersionResource(exe.targetName)
File "C:\Python27\lib\site-packages\cx_Freeze\freezer.py", line 150, in _AddVersionResource
stamp(fileName, versionInfo)
File "C:\Python27\lib\site-packages\win32\lib\win32verstamp.py", line 159, in stamp
h = BeginUpdateResource(pathname, 0)
pywintypes.error: (2, 'BeginUpdateResource', 'The system cannot find the file specified.')
Adding a .exe at the target name does resolve this
Reposting as an answer:
targetName is the filename of the executable it's going to produce. On Windows, executables must have a .exe extension, so you'll need to set it as 'hello.exe' rather than just 'hello'.
I ran into this problem with the latest version of Cx_freeze.
I found that I needed to change my Executable call in the setup.py to use a relative path for the dist directory.
Changes needed in setup.py
From
MyExe_Target_1 = Executable(
# what to build
script = "main.py",
initScript = None,
base = None,
targetDir = r"dist",
targetName = "MyWindowsApp.exe",
compress = True,
copyDependentFiles = True,
appendScriptToExe = False,
appendScriptToLibrary = False,
icon = None
)
To:
MyExe_Target_1 = Executable(
# what to build
script = "main.py",
initScript = None,
base = None,
targetDir = r".\\dist", # needs in Windows format relative to the working dir!
targetName = "MyWindowsApp.exe",
compress = True,
copyDependentFiles = True,
appendScriptToExe = False,
appendScriptToLibrary = False,
icon = None
)
I am using cx_Freeze with Python 3.4.1 and I am trying to create an application from one of my Python programs. Unfortunately, I get this error after running the setup.py build:
cx_Freeze.freezer.ConfigError: cannot find file/directory named icon.gif
Here is my setup file:
import sys
from cx_Freeze import setup, Executable
base = None
if sys.platform == "win32" : base = "Win32GUI"
opts = {"include_files": ['icon.gif', "EndingsPerfect.txt", "EndingsPPP.txt", "LatinEnglishPronouns.txt", "1stConj/", "2ndConj/", "3rdConj/", "4thConj/"], "includes": ["re"]}
setup(name = "LT",
version = "1.0",
description = "Latin verbs",
author = "Laurence vS",
options = {"build_exe": opts},
executables = [Executable("latintranslatewithguipyw.pyw", base = base)])
This error confuses me since the icon.gif file is in the same folder as the setup file.
Here is the full traceback:
C:\Users\Laurence> python "C:\Users\Laurence\Dropbox\Python programs\GUIs\latintr
anslatewithgui\setup.py" build
running build
running build_exe
Traceback (most recent call last):
File "C:\Users\Laurence\Dropbox\Python programs\GUIs\latintranslatewithgui\set
up.py", line 14, in <module>
executables = [Executable("latintranslatewithguipyw.pyw", base = base)])
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 108, in __init
__
self._VerifyConfiguration()
File "C:\Python34\lib\site-packages\cx_Freeze\freezer.py", line 498, in _Verif
yConfiguration
sourceFileName)
cx_Freeze.freezer.ConfigError: cannot find file/directory named icon.gif
Any help would be appreciated.
Reposting as an answer:
Relative path names are found relative to where you run from, not where the the setup.py script is. Use cd in the terminal to change to the directory where setup.py is, and then run python setup.py build.
If that's not practical for some reason, you could use os.chdir() inside the setup.py script.