Getting an odd error trying to compile a Python Executable - python

I'm attempting to use Py2exe to create a Python executable out of my program. The program definitely works and I've made sure all the libraries it uses are up to date, but when I attempt to run the command "python setup.py py2exe" to finish it up, I get an error I'm unfamiliar with.
The full output is below:
running py2exe
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\site-packages\setuptools\distutils_patch.py:25: UserWarning: Distutils was imported before Setuptools. This usage is discouraged and may exhibit undesirable behaviors or errors. Please use Setuptools' objects directly or at least import Setuptools first.
warnings.warn(
Traceback (most recent call last):
File "C:\Users\user\OneDrive\Desktop\intern\pdf\setup.py", line 11, in
setup(console=[{ "script": "tca_script.py"}],
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\py2exe\distutils_buildexe.py", line 192, in run
self._run()
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\py2exe\distutils_buildexe.py", line 272, in _run
builder.analyze()
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\py2exe\runtime.py", line 172, in analyze
mf.import_package(modname)
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\py2exe\mf34.py", line 84, in import_package
self.import_package("%s.%s" % (name, modname))
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\py2exe\mf34.py", line 84, in import_package
self.import_package("%s.%s" % (name, modname))
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\py2exe\mf34.py", line 84, in import_package
self.import_package("%s.%s" % (name, modname))
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\py2exe\mf34.py", line 71, in import_package
package = self.modules[name]
KeyError: 'pandas.tests.io.excel'
Any help would be greatly appreciated.

Related

Error while trying to compile Python script to exe

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/

Value error '/anaconda3/lib/libpython3.7.dylib' does not exist?

so I've created a virtual environment in my iterm2 window. this is the ques I asked earlier which has not been solved yet and my app is not running is alias modeso i tried to do the whole process again but it was showing error with plistlib so that was fixed by this answer I tried this whole process again which means I did this all this before but my app was not working so i deleted my py2app and some venv's got deleted to I downloaded miniconda3 again and then it was working until it comes to running the app even in alias mode . but I continued and deleted the dist and build and when I executed
python setup.py py2app but then i got this error
Traceback (most recent call last):
File "setup.py", line 18, in <module>
setup_requires=['py2app'],
File "/Users/divyabansal/divya/lib/python3.7/site-packages/setuptools/__init__.py", line
145, in setup
return distutils.core.setup(**attrs)
File "/Users/divyabansal/miniconda3/lib/python3.7/distutils/core.py", line 148, in setup
dist.run_commands()
File "/Users/divyabansal/miniconda3/lib/python3.7/distutils/dist.py", line 966, in
run_commands
self.run_command(cmd)
File "/Users/divyabansal/miniconda3/lib/python3.7/distutils/dist.py", line 985, in
run_command
cmd_obj.run()
File "/Users/divyabansal/divya/lib/python3.7/site-packages/py2app/build_app.py", line 756,
in run
self._run()
File "/Users/divyabansal/divya/lib/python3.7/site-packages/py2app/build_app.py", line 966,
in _run
self.run_normal()
File "/Users/divyabansal/divya/lib/python3.7/site-packages/py2app/build_app.py", line 1074,
in run_normal
self.create_binaries(py_files, pkgdirs, extensions, loader_files)
File "/Users/divyabansal/divya/lib/python3.7/site-packages/py2app/build_app.py", line 1384,
in create_binaries
mm.mm.run_file(runtime)
File "/Users/divyabansal/divya/lib/python3.7/site-packages/macholib/MachOGraph.py", line 89,
in run_file
raise ValueError("%r does not exist" % (pathname,))
ValueError: '/Users/divyabansal/miniconda3/lib/libpython3.7.dylib'
does not exist
please help me with this problem
Thank You!
This problem can often be fixed by creating a symlink, see here for more.
ln -s /path/to/lib/libpython3.7m.dylib /path/to/lib/libpython3.7.dylib
For the above command replace it with your own path.

error when installing numpy for pypy2.2.1

I am trying to use pypy. My python scripts are using numpy. So when I used pypy 1.9.0 it showed me this:
"The 'numpy' module of PyPy is in-development and not complete. "
ImportError: The '`numpy' module` of PyPy is in-development and not complete. To try it out anyway, you can either import from 'numpypy', or just write 'import numpypy' first in your program and then import from 'numpy' as usual.
So I used import numpypy and then ran my script. I got this error:
File "customecode.py", line 97, in dist_new
dlat = radians(p2[..., 0] - p1[..., 0])
TypeError: expected integer, got Ellipsis object
I couldn't find anything on this kind of error. Although script is running fine when I use python. So my guess is that may be pypy still don't support everything which is there on numpy.
I found this link on pypy-numpy update. So I install pypy 2.2.1
http://morepypy.blogspot.in/2013/11/numpy-status-update.html
In this link following instructions are given for installing numpy for pypy:
git clone https://bitbucket.org/pypy/numpy.git
cd numpy
pypy setup.py install
after running pypy setup.py installI got this type error:
Traceback (most recent call last):
File "app_main.py", line 51, in run_toplevel
File "setup.py", line 239, in <module>
setup_package()
File "setup.py", line 231, in setup_package
setup(**metadata)
File "/home/administrator/numpy/numpy/distutils/core.py", line 169, in setup
return old_setup(**new_attr)
File "/usr/lib/pypy/lib-python/2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib/pypy/lib-python/2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/pypy/lib-python/2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/home/administrator/numpy/numpy/distutils/command/install.py", line 57, in run
r = old_install.run(self)
File "/usr/lib/pypy/lib-python/2.7/distutils/command/install.py", line 613, in run
self.run_command('build')
File "/usr/lib/pypy/lib-python/2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/usr/lib/pypy/lib-python/2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/home/administrator/numpy/numpy/distutils/command/build.py", line 39, in run
old_build.run(self)
File "/usr/lib/pypy/lib-python/2.7/distutils/command/build.py", line 127, in run
self.run_command(cmd_name)
File "/usr/lib/pypy/lib-python/2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/usr/lib/pypy/lib-python/2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/home/administrator/numpy/numpy/distutils/command/build_src.py", line 153, in run
self.build_sources()
File "/home/administrator/numpy/numpy/distutils/command/build_src.py", line 164, in build_sources
self.build_library_sources(*libname_info)
File "/home/administrator/numpy/numpy/distutils/command/build_src.py", line 299, in build_library_sources
sources = self.generate_sources(sources, (lib_name, build_info))
File "/home/administrator/numpy/numpy/distutils/command/build_src.py", line 386, in generate_sources
source = func(extension, build_dir)
File "numpy/core/setup.py", line 678, in get_mathlib_info
st = config_cmd.try_link('int main(void) { return 0;}')
File "/usr/lib/pypy/lib-python/2.7/distutils/command/config.py", line 248, in try_link
self._check_compiler()
File "/home/administrator/numpy/numpy/distutils/command/config.py", line 46, in _check_compiler
old_config._check_compiler(self)
File "/usr/lib/pypy/lib-python/2.7/distutils/command/config.py", line 103, in _check_compiler
customize_compiler(self.compiler)
File "/usr/lib/pypy/lib-python/2.7/distutils/ccompiler.py", line 44, in customize_compiler
cpp = cc + " -E" # not always
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
I want to use pypy 2.2.1 with whatever development of numpy provided there. Any help with the installation of numpy for pypy is appreciated.
In PyPy 2.2.1, the file lib-python/2.7/distutils/ccompiler.py does not contain any function called customize_compiler() and line 44 is not like that. My guess is that your version of PyPy's standard library has been tweaked by your Linux distribution in a way that makes it crash in your particular case.
I can only suggest that you try to get the "official" PyPy 2.2.1 and compare the results.

Creating an executable from a python GUI using py2exe

I have a .py file that creates a GUI, which runs another script once I give it some information. I'm trying to make a .exe file from this GUI file using py2exe, but I've been having trouble.
Exception: Seems not to be an exe-file
If anyone who has experience with py2exe and has encountered this message before, could you explain to me why it's not working, and what I could do to fix it? Thanks in advance.
EDIT: My setup.py looks like this:
from distutils.core import setup
import py2exe
setup(console=['test_gui.py'])
I run this code through the command prompt like this:
python setup.py py2exe
And the traceback is as follows:
Traceback (most recent call last):
File "setup.py", line 4, in <module>
setup(console=['test_gui.py'])
File "C:\Python26\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "C:\Python26\lib\distutils\dist.py", line 975, in run_commands
self.run_command(cmd)
File "C:\Python26\lib\distutils\dist.py", line 995, in run_command
cmd_obj.run()
File "C:\Python26\Lib\site-packages\py2exe\build_exe.py", line 243, in run
self._run()
File "C:\Python26\Lib\site-packages\py2exe\build_exe.py", line 305, in _run
dlls = self.find_dlls(extensions)
File "C:\Python26\Lib\site-packages\py2exe\build_exe.py", line 389, in find_dlls
self.dll_excludes)
File "C:\Python26\Lib\site-packages\py2exe\build_exe.py", line 1064, in find_d
ependend_dlls
bin_depends(loadpath, images + [sys.executable], excludes_use)
File "C:\Python26\Lib\site-packages\py2exe\build_exe.py", line 1441, in bin_de
pends
if isSystemDLL(dll):
File "C:\Python26\Lib\site-packages\py2exe\build_exe.py", line 1498, in isSyst
emDLL
raise Exception, "Seems not to be an exe-file"
Exception: Seems not to be an exe-file

How to install django-utils?

I tried installing django-utils from source code from github and using pip. The installation goes fine however the queue_command does not work within my django app.
So as suggested in the docs, I tried running `python setup.py test' and I get the following error. I have not idea how to fix this. I am running from within virtualenv on mac snow leopard.
Any suggestions? Thank you.
running test
running egg_info
writing djutils.egg-info/PKG-INFO
writing top-level names to djutils.egg-info/top_level.txt
writing dependency_links to djutils.egg-info/dependency_links.txt
reading manifest file 'djutils.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'LICENSE.txt'
writing manifest file 'djutils.egg-info/SOURCES.txt'
running build_ext
Traceback (most recent call last):
File "setup.py", line 33, in <module>
tests_require=['pygments', 'PIL>=0.1.5', 'httplib2'],
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "build/bdist.linux-i686/egg/setuptools/command/test.py", line 121, in run
File "build/bdist.linux-i686/egg/setuptools/command/test.py", line 101, in with_project_on_sys_path
File "build/bdist.linux-i686/egg/setuptools/command/test.py", line 130, in run_tests
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 94, in __init__
self.parseArgs(argv)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 149, in parseArgs
self.createTests()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 158, in createTests
self.module)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 128, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 91, in loadTestsFromName
module = __import__('.'.join(parts_copy))
File "/Users/miki725/Development/libs/django-utils/runtests.py", line 43, in <module>
from django.test.simple import run_tests
File "/Users/miki725/Development/Django/lib/python2.7/site-packages/django/test/__init__.py", line 5, in <module>
from django.test.client import Client, RequestFactory
File "/Users/miki725/Development/Django/lib/python2.7/site-packages/django/test/client.py", line 27, in <module>
from django.db import close_connection
File "/Users/miki725/Development/Django/lib/python2.7/site-packages/django/db/__init__.py", line 40, in <module>
backend = load_backend(connection.settings_dict['ENGINE'])
File "/Users/miki725/Development/Django/lib/python2.7/site-packages/django/db/__init__.py", line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Users/miki725/Development/Django/lib/python2.7/site-packages/django/db/utils.py", line 92, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Users/miki725/Development/Django/lib/python2.7/site-packages/django/db/utils.py", line 51, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'sqlite3' isn't an available database backend.
Try using django.db.backends.sqlite3 instead.
Error was: No module named base
What version of Django are you running? 1.3 deprecated the old-style way of specifying databases, for example, using just 'sqlite3'. You now must specify the entire import path, i.e. django.db.backends.sqlite3.
However, I was pretty sure that 1.3 still let you use the old-style way and simply fussed at you, warning that it's deprecated. Perhaps I was wrong though. If you're running off trunk, then, it's almost certainly fully deprecated, which makes that error a little more understandable.
The long and short is that since the last update of django-utils was back in 2009, it's effectively dead, and Django has moved on.
Open your settings.py
Replace 'ENGINE': 'sqlite3', with 'ENGINE': 'django.db.backends.sqlite3',
Save
Try again.

Categories

Resources