First time trying to use cx_Freeze, I'm trying to build a little game I made in PyGame. However, I'm getting an error. Here is my setup.py :
from cx_Freeze import setup, Executable
executables = [Executable("main.py", base = None)]
options = {
'packages': ["idna", "numpy", "pygame"]
}
setup(
name = "TheMaze",
options = {"build_exe": options},
version = "1.0",
description = 'My first game!',
executables = executables
)
I'm getting the following error :
Traceback (most recent call last):
File "setup.py", line 14, in <module>
executables = executables
File "P:\Programmes\Anaconda3\lib\site-packages\cx_Freeze\dist.py", line 340, in setup
distutils.core.setup(**attrs)
File "P:\Programmes\Anaconda3\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "P:\Programmes\Anaconda3\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "P:\Programmes\Anaconda3\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "P:\Programmes\Anaconda3\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "P:\Programmes\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "P:\Programmes\Anaconda3\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "P:\Programmes\Anaconda3\lib\site-packages\cx_Freeze\dist.py", line 211, in run
freezer.Freeze()
File "P:\Programmes\Anaconda3\lib\site-packages\cx_Freeze\freezer.py", line 612, in Freeze
self._FreezeExecutable(executable)
File "P:\Programmes\Anaconda3\lib\site-packages\cx_Freeze\freezer.py", line 211, in _FreezeExecutable
self._AddVersionResource(exe)
File "P:\Programmes\Anaconda3\lib\site-packages\cx_Freeze\freezer.py", line 127, in _AddVersionResource
stamp(fileName, versionInfo)
File "P:\Programmes\Anaconda3\lib\site-packages\win32\lib\win32verstamp.py", line 163, in stamp
h = BeginUpdateResource(pathname, 0)
pywintypes.error: (2, 'BeginUpdateResource', 'The system cannot find the file specified.')
I've tried several things based on examples I could find on the internet, but I couldn't manage to make ti works.
Related
I have Python version 2.7, cx_freeze version 5.0 and Ubuntu 16.04.
On running the command python2 setup.py buildin the requisite directory, I am getting the following error:
running build
running build_exe
Traceback (most recent call last):
File "setup.py", line 39, in <module>
executables = executables
File "/usr/lib/python2.7/dist-packages/cx_Freeze/dist.py", line 349, in setup
distutils.core.setup(**attrs)
File "/usr/lib/python2.7/distutils/core.py", line 151, 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/lib/python2.7/dist-packages/cx_Freeze/dist.py", line 219, in run
freezer.Freeze()
File "/usr/lib/python2.7/dist-packages/cx_Freeze/freezer.py", line 618, in Freeze
import cx_Freeze.util
ImportError: No module named util
cx_freeze has its source code here and here. I thought of downloading the util file to the cx_freeze folder on my local machine but neither did I get it nor am I sure of the validness of this method.
So, how do I solve this issue ?
I am trying to make a script executable with py2exe.
Here is my setup.py code:
import cx_Freeze
executables = [cx_Freeze.Executable("Email.py")]
cx_Freeze.setup(
name="Email",
options={"build_exe": {"packages":["pygame"],
"include_files":["aura.png"]}},
executables = executables
)
And I run this from my cmd and here is the execution:
G:\Grade 12 Project>python setup.py build 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\Email.exe copying C:\WINDOWS\SYSTEM32\python27.dll
-> build\exe.win32-2.7\python27.dll Traceback (most recent call last): File "setup.py", line 9, in <module>
executables = executables File "C:\Python27\lib\site-packages\cx_Freeze\dist.py", line 349, 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 219, in run
freezer.Freeze() File "C:\Python27\lib\site-packages\cx_Freeze\freezer.py", line 623, in Freeze
self._FreezeExecutable(executable) File "C:\Python27\lib\site-packages\cx_Freeze\freezer.py", line 225, in
_FreezeExecutable
self._AddVersionResource(exe) File "C:\Python27\lib\site-packages\cx_Freeze\freezer.py", line 165, in
_AddVersionResource
trademarks = exe.trademarks) File "C:\Python27\lib\site-packages\cx_Freeze\freezer.py", line 759, in
__init__
parts = version.split(".") AttributeError: 'NoneType' object has no attribute 'split'
Also in my build folder , when I run Email.exe, I get this error:
ImportError: No module named __startup__
As #Mohammad Yusuf Ghazi said, you need to pass a version='x.y.z' parameter into the setup call, e.g:
cx_Freeze.setup(
name="Email",
options={
"build_exe": {"packages":["pygame"],
"include_files":["aura.png"]}},
executables = executables,
version='1.0.0'
)
It's not valid to call setup without a version number.
Are you trying to run this from the command line or from the GUI? If from the GUI you may need to call Executable("Email.py", base="Win32GUI") as per the docs in order for it to work, so that might be the problem. But it would help to see the full traceback.
I am attempting to make my first .exe file using cx_freeze on 32-bit Ubuntu, but am encountering an unexplained TypeError. I expect I have done something wrong in my setup file, but have yet to find what it might be. Here is the setup script:
import sys
from cx_Freeze import setup, Executable
exe = Executable(
script = 'cornell7.py',
targetName = 'cornell7.exe',
packages = ['header2.py'],
targetDir = 'executable_dir',
includes = [ 'urllib.request', 'socket', 'sys', 'string', 'threading', 'time','datetime'],
copyDependentFiles = True
)
setup( name = 'cornell7.exe',
executables = [exe]
)
(header2.py is a module I myself wrote containing several useful functions)
Here is the command I've been running in the terminal:
python setup.py build
When I enter that command, I get the following error message:
running build
running build_exe
Traceback (most recent call last):
File "setup.py", line 14, in <module>
executables = [exe]
File "/usr/lib/pymodules/python2.7/cx_Freeze/dist.py", line 278, 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/lib/pymodules/python2.7/cx_Freeze/dist.py", line 165, in run
freezer.Freeze()
File "/usr/lib/pymodules/python2.7/cx_Freeze/freezer.py", line 405, in Freeze
self._FreezeExecutable(executable)
File "/usr/lib/pymodules/python2.7/cx_Freeze/freezer.py", line 149, in _FreezeExecutable
scriptModule = finder.IncludeFile(exe.script, exe.moduleName)
File "/usr/lib/pymodules/python2.7/cx_Freeze/finder.py", line 391, in IncludeFile
deferredImports)
File "/usr/lib/pymodules/python2.7/cx_Freeze/finder.py", line 286, in _LoadModule
self._ScanCode(module.code, module, deferredImports)
File "/usr/lib/pymodules/python2.7/cx_Freeze/finder.py", line 353, in _ScanCode
module, relativeImportIndex)
File "/usr/lib/pymodules/python2.7/cx_Freeze/finder.py", line 176, in _ImportModule
deferredImports)
File "/usr/lib/pymodules/python2.7/cx_Freeze/finder.py", line 246, in _InternalImportModule
parentModule)
File "/usr/lib/pymodules/python2.7/cx_Freeze/finder.py", line 286, in _LoadModule
self._ScanCode(module.code, module, deferredImports)
File "/usr/lib/pymodules/python2.7/cx_Freeze/finder.py", line 353, in _ScanCode
module, relativeImportIndex)
File "/usr/lib/pymodules/python2.7/cx_Freeze/finder.py", line 176, in _ImportModule
deferredImports)
File "/usr/lib/pymodules/python2.7/cx_Freeze/finder.py", line 241, in _InternalImportModule
fp, path, info = self._FindModule(searchName, path)
File "/usr/lib/pymodules/python2.7/cx_Freeze/finder.py", line 84, in _FindModule
for location in path:
TypeError: 'NoneType' object is not iterable
So far as I can tell, I've obeyed the cx_freeze documentation faithfully.
I'm not a cx_freeze expert, but your executable definition looks wrong. The packages argument is supposed to take a list of packages (that is, folders containing __init__.py and zero or more other Python files), not of Python modules (individual .py files).
For more information on the difference between modules and packages, see http://docs.python.org/2/tutorial/modules.html
I am trying to install rpy2-2.3.1 on Windows 7, using the source files under rpy2-2.3.1.tar.gz.
However, upon running setup.py on the command prompt, I get the trace-back below. I have checked a few stack-overflow posts on installing RPy2 on windows 7 and am already aware that it is a challenge. Does anyone have an idea what went wrong in my case?
Thanks in advance.
P.S: I cannot install it using the .exe since I get the 'Python version 2.7. required, which was not found in the registry' warning and do not have privileges to update the registry. So it is not an option for me.
P.S2: Before I started getting this trace-back I set up the R path as: C:\Program Files\R\R-3.01\bin. This I believe points to a 64-bit R. May this be causing the problem?
I:\Documents\Visual Studio 2010\Projects\MyProject\rpy2-2.3.1>C:/Python27/python.exe setup.py install
running install
running build
running build_py
running build_ext
Traceback (most recent call last):
File "setup.py", line 463, in <module>
'rpy2': ['doc/source/rpy2_logo.png', ]}
File "C:\u\windows\Python27\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "C:\u\windows\Python27\lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd)
File "C:\u\windows\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\u\windows\Python27\lib\distutils\command\install.py", line 563, in run
self.run_command('build')
File "C:\u\windows\Python27\lib\distutils\cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "C:\u\windows\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\u\windows\Python27\lib\distutils\command\build.py", line 127, in run
self.run_command(cmd_name)
File "C:\u\windows\Python27\lib\distutils\cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "C:\u\windows\Python27\lib\distutils\dist.py", line 971, in run_command
cmd_obj.ensure_finalized()
File "C:\u\windows\Python27\lib\distutils\cmd.py", line 109, in ensure_finalized
self.finalize_options()
File "setup.py", line 163, in finalize_options
config += get_rconfig(r_home, about)
File "setup.py", line 333, in get_rconfig
rc = RConfig.from_string(rconfig, allow_empty = allow_empty)
File "setup.py", line 293, in from_string
+ '\nin string\n' + string)
ValueError: Invalid substring
in string
This site has what you are looking for. It has a lot of good modules in .exe format:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#rpy2
I'm trying to compile Python 2.7 installer on Windows. The compilation works fine, but when I try to run
PCbuild\python.exe setup.py bdist_wininst
I get an error:
error: pyconfig.h: No such file or directory
How can I fix that?
Update:
I found a file called Pyconfig.h.in in the root directory. After renaimnig it to Pyconfig.h bdist fails with the following error:
Traceback (most recent call last):
File "setup.py", line 2076, in <module>
main()
File "setup.py", line 2071, in main
'Lib/smtpd.py']
File "Python-2.7.3\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "Python-2.7.3\lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd)
File "Python-2.7.3\Python-2.7.3\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "Python-2.7.3\lib\distutils\command\bdist_wininst.py", line 131, in run
self.run_command('build')
File "Python-2.7.3\lib\distutils\cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "Python-2.7.3\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "Python-2.7.3\lib\distutils\command\build.py", line 127, in run
self.run_command(cmd_name)
File "Python-2.7.3\lib\distutils\cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "Python-2.7.3\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "Python-2.7.3\lib\distutils\command\build_ext.py", line 339, in run
self.build_extensions()
File "setup.py", line 152, in build_extensions
missing = self.detect_modules()
File "setup.py", line 1146, in detect_modules
for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
AttributeError: 'NoneType' object has no attribute 'split'
Thanks in advance, Ivan.