Error generate executable in Python. (py2exe) - python

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

Related

The following error occurred while using py2exe

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

AttributeError with cx_Freeze

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
)

NameError py2app in modulegraph

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

cannot import name ContextualZipFile when installing Cython

I downloaded Cython and run:
sudo python setup.py install
and I get the following error:
Unable to find pgen, not compiling formal grammar.
running install
Traceback (most recent call last):
File "setup.py", line 357, in <module>
**setup_args
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/local/lib/python2.7/dist-packages/setuptools/command/install.py", line 67, in run
self.do_egg_install()
File "/usr/local/lib/python2.7/dist-packages/setuptools/command/install.py", line 98, in do_egg_install
easy_install = self.distribution.get_command_class('easy_install')
File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 388, in get_command_class
self.cmdclass[command] = cmdclass = ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2088, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 42, in <module>
from setuptools.archive_util import unpack_archive
File "/usr/local/lib/python2.7/dist-packages/setuptools/archive_util.py", line 15, in <module>
from pkg_resources import ensure_directory, ContextualZipFile
ImportError: cannot import name ContextualZipFile
I also get the same error when I install with pip install.

How can a module with setup.py installed using Cython?

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.

Categories