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
Related
I am trying to install scipy 1.0.0 in a conda env for another software called GATK.
I installed python 3.6.10 and numpy 1.17.5, which are said to be compatible with scipy 1.0.0 (both in the yml file provided by GATK)
However, when I tried installing via python setup.py build, it returns error message as below. I searched by seems like others are mostly struggling with scipy 1.1.0 or some other errors.
Really appreciate any help!
Thanks!
f2py: build/src.linux-x86_64-3.6/scipy/linalg/flapack.pyf
Reading fortran codes...
Reading file 'build/src.linux-x86_64-3.6/scipy/linalg/flapack.pyf' (format:free)
Traceback (most recent call last):
File "setup.py", line 418, in <module>
setup_package()
File "setup.py", line 414, in setup_package
setup(**metadata)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/distutils/core.py", line 171, in setup
return old_setup(**new_attr)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/setuptools/__init__.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/distutils/command/build.py", line 47, in run
old_build.run(self)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/distutils/command/build_src.py", line 142, in run
self.build_sources()
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/distutils/command/build_src.py", line 159, in build_sources
self.build_extension_sources(ext)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/distutils/command/build_src.py", line 319, in build_extension_sources
sources = self.f2py_sources(sources, ext)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/distutils/command/build_src.py", line 535, in f2py_sources
+ ['--build-dir', target_dir, source])
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/f2py/f2py2e.py", line 425, in run_main
postlist = callcrackfortran(files, options)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/f2py/f2py2e.py", line 330, in callcrackfortran
postlist = crackfortran.crackfortran(files)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/f2py/crackfortran.py", line 3251, in crackfortran
readfortrancode(files, crackline)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/f2py/crackfortran.py", line 501, in readfortrancode
dowithline(finalline)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/f2py/crackfortran.py", line 796, in crackline
analyzeline(m, pat[1], line)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/f2py/crackfortran.py", line 1098, in analyzeline
last_name = updatevars(typespec, selector, attr, edecl)
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/f2py/crackfortran.py", line 1542, in updatevars
attrspec = [x.strip() for x in markoutercomma(attrspec).split('#,#')]
File "/home/joyzheng/.conda/envs/gatk4.3/lib/python3.6/site-packages/numpy/f2py/crackfortran.py", line 833, in markoutercomma
assert not f, repr((f, line, l))
AssertionError: (-1, 'intent(in))', 'intent(in))')```
- List item
could somebody help me with this?
I just simple follow the instruction of megvii
python setup.py develop
the problem comeup:
(newtorch) PS D:\codeofpaper\YOLOX-main> python setup.py develop
running develop
running egg_info
writing yolox.egg-info\PKG-INFO
writing dependency_links to yolox.egg-info\dependency_links.txt
writing top-level names to yolox.egg-info\top_level.txt
reading manifest file 'yolox.egg-info\SOURCES.txt'
adding license file 'LICENSE'
writing manifest file 'yolox.egg-info\SOURCES.txt'
running build_ext
Traceback (most recent call last):
File "setup.py", line 63, in <module>
packages=setuptools.find_packages(),
File "D:\Anaconda\Anaconda3\envs\newtorch\lib\site-packages\setuptools\__init__.py", line 153, in setup
return distutils.core.setup(**attrs)
File "D:\Anaconda\Anaconda3\envs\newtorch\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "D:\Anaconda\Anaconda3\envs\newtorch\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "D:\Anaconda\Anaconda3\envs\newtorch\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "D:\Anaconda\Anaconda3\envs\newtorch\lib\site-packages\setuptools\command\develop.py", line 34, in run
self.install_for_development()
File "D:\Anaconda\Anaconda3\envs\newtorch\lib\site-packages\setuptools\command\develop.py", line 114, in install_for_development
self.run_command('build_ext')
File "D:\Anaconda\Anaconda3\envs\newtorch\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "D:\Anaconda\Anaconda3\envs\newtorch\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "D:\Anaconda\Anaconda3\envs\newtorch\lib\site-packages\setuptools\command\build_ext.py", line 79, in run
_build_ext.run(self)
File "D:\Anaconda\Anaconda3\envs\newtorch\lib\site-packages\Cython\Distutils\old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "D:\Anaconda\Anaconda3\envs\newtorch\lib\distutils\command\build_ext.py", line 309, in run
force=self.force)
File "D:\Anaconda\Anaconda3\envs\newtorch\lib\distutils\ccompiler.py", line 1032, in new_compiler
return klass(None, dry_run, force)
File "D:\Anaconda\Anaconda3\envs\newtorch\lib\distutils\cygwinccompiler.py", line 285, in __init__
CygwinCCompiler.__init__ (self, verbose, dry_run, force)
File "D:\Anaconda\Anaconda3\envs\newtorch\lib\distutils\cygwinccompiler.py", line 129, in __init__
if self.ld_version >= "2.10.90":
TypeError: '>=' not supported between instances of 'NoneType' and 'str'
MY CMDline output
I don't kbow what to do?
My cp is Windows10,and I use anaconda virtual env
This means that gcc was not found on your computer, i.e. cygwin is not set up correctly. distutils tries to find the version with this line:
commands = ['gcc -dumpversion', 'ld -v', 'dllwrap --version']
return tuple([_find_exe_version(cmd) for cmd in commands])
So make sure that your PATH is set up correctly so that you can run these commands from the same terminal from which you executed your pip install
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.
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 trying to run a python project that I have not written myself. This has required me to install a series of new libraries, but more importantly, it has required me to install Cython.
I think I've installed Cython succesfully at this point. I am using MinGW for my compiler. When I try to run the project I get the error
ImportError: Building module RayTrace failed: ['DistutilsPlatformError: Unable to find vcvarsall.bat\n']
As far as I've understood this is about setting the path for the compiler. I have created the distutils.cfg file that says MinGW is the compiler as well as put MinGW in Path.
Where do I go from here?
this is the complete traceback:
Traceback (most recent call last):
File "C:\Users\Marten\Python\DisperseIt\DisperseIt.py", line 5, in <module>
from DisperseProjectDisperseCtrlFrame import *
File "C:\Users\Marten\Python\DisperseIt\DisperseProjectDisperseCtrlFrame.py", line 12, in <module>
import SectionCalc
File "C:\Users\Marten\Python\DisperseIt\SectionCalc.py", line 10, in <module>
from RayTrace import CalcIndices
File "C:\Python27\lib\site-packages\cython-0.20.2-py2.7-win32.egg\pyximport\pyximport.py", line 431, in load_module
language_level=self.language_level)
File "C:\Python27\lib\site-packages\cython-0.20.2-py2.7-win32.egg\pyximport\pyximport.py", line 209, in load_module
inplace=build_inplace, language_level=language_level)
File "C:\Python27\lib\site-packages\cython-0.20.2-py2.7-win32.egg\pyximport\pyximport.py", line 186, in build_module
reload_support=pyxargs.reload_support)
File "C:\Python27\lib\site-packages\cython-0.20.2-py2.7-win32.egg\pyximport\pyxbuild.py", line 104, in pyx_to_dll
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\site-packages\cython-0.20.2-py2.7-win32.egg\Cython\Distutils\build_ext.py", line 163, in run
_build_ext.build_ext.run(self)
File "C:\Python27\lib\distutils\command\build_ext.py", line 337, in run
self.build_extensions()
File "C:\Python27\lib\site-packages\cython-0.20.2-py2.7-win32.egg\Cython\Distutils\build_ext.py", line 171, in build_extensions
self.build_extension(ext)
File "C:\Python27\lib\distutils\command\build_ext.py", line 496, in build_extension
depends=ext.depends)
File "C:\Python27\lib\distutils\msvc9compiler.py", line 473, in compile
self.initialize()
File "C:\Python27\lib\distutils\msvc9compiler.py", line 383, in initialize
vc_env = query_vcvarsall(VERSION, plat_spec)
File "C:\Python27\lib\distutils\msvc9compiler.py", line 271, in query_vcvarsall
raise DistutilsPlatformError("Unable to find vcvarsall.bat")
ImportError: Building module RayTrace failed: ['DistutilsPlatformError: Unable to find vcvarsall.bat\n']