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']}
Related
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 am trying to build my wxPython application with Python 3 using py2app. Before I updated my code to Python 3, I was able to do this successfully in Python 2.
After fixing a few initial problems (had to sys.setrecursionlimit(2000) and downgrade to Python 3.5), I got stuck here:
Traceback (most recent call last):
File "setup_pmag_gui.py", line 23, in <module>
setup_requires=['py2app'],
File "/Users/****/anaconda/lib/python3.5/distutils/core.py", line 148, in setup
dist.run_commands()
File "/Users/****/anaconda/lib/python3.5/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/Users/****/anaconda/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/Users/****/my_project/.eggs/py2app-0.13-py3.5.egg/py2app/build_app.py", line 757, in run
self._run()
File "/Users/****/my_project/.eggs/py2app-0.13-py3.5.egg/py2app/build_app.py", line 967, in _run
self.run_normal()
File "/Users/****/my_project/.eggs/py2app-0.13-py3.5.egg/py2app/build_app.py", line 1075, in run_normal
self.create_binaries(py_files, pkgdirs, extensions, loader_files)
File "/Users/****/my_project/.eggs/py2app-0.13-py3.5.egg/py2app/build_app.py", line 1385, in create_binaries
mm.mm.run_file(runtime)
File "/Users/****/my_project/.eggs/macholib-1.8-py3.5.egg/macholib/MachOGraph.py", line 83, in run_file
ValueError: '/Users/****/anaconda/lib/libpython3.5.dylib' does not exist
/Users/****/anaconda/lib/libpython3.5m.dylib does exist, though. Is there a way to tell MachOGraph how to find this?
I am on OS X 10.12.4, using Anaconda Python 3.5. My version of py2app is 0.13.
This is what my setup.py file looks like:
from setuptools import setup
import sys
import os
directory = os.getcwd()
sys.setrecursionlimit(3000)
APP = ['programs/pmag_gui.py']
DATA_FILES = [('', ['dialogs/help_files', 'pmagpy/data_model', 'programs/images'])]
OPTIONS = {'argv_emulation': False,
'iconfile': os.path.join(directory, 'programs', 'images', 'text_x_xslfo.icns')}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
After reading the Tweaking your Info.plist py2app documentation, and this question, I tried adding to OPTIONS:
'plist': dict(PyRuntimeLocations=['/Users/****/anaconda/lib/libpython3.5m.dylib'])
But I get the same exact error message as before.
Any suggestions on how to solve this, or what documentation to look at?
I had same problem with miniconda and py2app. I could fix it by creating a symlink!
ln -s /path/to/lib/libpython3.5m.dylib /path/to/lib/libpython3.5.dylib
I'm trying to package an app and include pymssql with it.
Here's my setup.py:
"""
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
"""
from setuptools import setup
APP = ['AppName.py']
DATA_FILES = ['pic1.jpg', 'pic2.jpeg']
OPTIONS = {'argv_emulation': True,
'packages': ['tkinter', '_mssql', 'pymssql']
}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
When I only include _mssql it gives this error:
error: cannot copy tree '/path_to_venv/lib/python3.4/site-packages/_mssql.so': not a directory
When I try with pymssql (or both) it gives this error:
Traceback (most recent call last):
File "setup.py", line 20, in <module>
setup_requires=['py2app'],
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/core.py", line 148, in setup
dist.run_commands()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/path_to_venv/lib/python3.4/site-packages/py2app/build_app.py", line 659, in run
self._run()
File "/path_to_venv/lib/python3.4/site-packages/py2app/build_app.py", line 865, in _run
self.run_normal()
File "/path_to_venv/lib/python3.4/site-packages/py2app/build_app.py", line 939, in run_normal
mf = self.get_modulefinder()
File "/path_to_venv/lib/python3.4/site-packages/py2app/build_app.py", line 814, in get_modulefinder
debug=debug,
File "/path_to_venv/lib/python3.4/site-packages/modulegraph/find_modules.py", line 341, in find_modules
find_needed_modules(mf, scripts, includes, packages)
File "/path_to_venv/lib/python3.4/site-packages/modulegraph/find_modules.py", line 266, in find_needed_modules
path = m.packagepath[0]
TypeError: 'NoneType' object is not subscriptable
Another note:
I can package the app fine without including either pymssql or _mssql in the setup file and when I try and run the app, here's the error I get in the OS Console:
1/12/16 10:00:48.618 AM AppName[72301]: Traceback (most recent call last):
1/12/16 10:00:48.618 AM AppName[72301]: File "/path_to_app/dist/AppName.app/Contents/Resources/__boot__.py", line 351, in <module>
1/12/16 10:00:48.618 AM AppName[72301]: _run()
1/12/16 10:00:48.619 AM AppName[72301]: File "/path_to_app/dist/AppName.app/Contents/Resources/__boot__.py", line 336, in _run
1/12/16 10:00:48.619 AM AppName[72301]: exec(compile(source, path, 'exec'), globals(), globals())
1/12/16 10:00:48.619 AM AppName[72301]: File "/path_to_app/dist/AppName.app/Contents/Resources/AppName.py", line 9, in <module>
1/12/16 10:00:48.619 AM AppName[72301]: import pymssql
1/12/16 10:00:48.619 AM AppName[72301]: File "_mssql.pxd", line 10, in init pymssql (pymssql.c:10984)
1/12/16 10:00:48.619 AM AppName[72301]: ImportError: No module named '_mssql'
I figured out a workaround. Probably not the best way, but it works now.
I added import _mssql into my main app script (already had import pymssql).
I then took my _mssql.pyx file and put a copy in my app dir.
I added _mssql.pyx under the DATA_FILES in the setup.py file.
You will need to include decimal and uuid into your setup.py file if not already included somewhere else.
Leave pymssql and _mssql out of the packages list in the setup.py file as py2app will find them and include them automatically.
You may need to include other libraries that the _mssql.pyx file will try and import. Just keep adding them until it works.
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.
When running 'python setup.py develop' or 'python setup.py install' I receive the following traceback.
Traceback (most recent call last):
File "setup.py", line 38, in <module>
test_suite='nose.collector',
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 "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/setuptools/command/develop.py", line 27, in run
self.install_for_development()
File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/setuptools/command/develop.py", line 129, in install_for_development
self.process_distribution(None, self.dist, not self.no_deps)
File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 682, in process_distribution
[requirement], self.local_index, self.easy_install
File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/pkg_resources.py", line 631, in resolve
dist = best[req.key] = env.best_match(req, ws, installer)
File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/pkg_resources.py", line 871, in best_match
return self.obtain(req, installer)
File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/pkg_resources.py", line 883, in obtain
return installer(requirement)
File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 595, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 627, in install_item
self.process_distribution(spec, dist, deps)
File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 659, in process_distribution
self.install_egg_scripts(dist)
File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/setuptools/command/develop.py", line 152, in install_egg_scripts
return easy_install.install_egg_scripts(self,dist)
File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 532, in install_egg_scripts
self.install_wrapper_scripts(dist)
File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 734, in install_wrapper_scripts
for args in get_script_args(dist):
File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/pbr/packaging.py", line 512, in override_get_script_args
header = easy_install.get_script_header("", executable, is_wininst)
AttributeError: 'NoneType' object has no attribute 'get_script_header'
Interestingly, if I rerun the same command as above, the installation is successful.
Just for kicks, I tried adding debugging statements to the pbr/packaging.py file both when easy_install was imported and used. It looked just fine when it was imported however, was None when accessed at line 512 as per the traceback.
Below is my requirements file that I am using:
pyyaml
requests
termcolor
mock
nose
cached_property
argparse
unittest2
tox
stevedore
kombu
and setup.py script:
import ez_setup
ez_setup.use_setuptools('3.6')
import os
from setuptools import setup, find_packages
try:
# workaround for http://bugs.python.org/issue15881
import multiprocessing # noqa
except ImportError:
pass
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
def requirements():
return read('requirements.txt').splitlines()
setup(
name='MY_PROJECT',
version='0.0.1',
author="Noorez Kassam",
long_description=read('README.rst'),
install_requires=requirements(),
entry_points={
'console_scripts': [
'myproj = myproj.myproj:main',
],
'myproj.urloperations.download': [
'file = myproj.filedownload:download'
],
},
packages=find_packages(),
test_suite='nose.collector',
)
Quick searches on Google indicate that others have encountered variations of what I am seeing however, I couldn't locate a solution to the problem.
I had a very similar problem and found a workaround.
I also got AttributeError: 'NoneType' object has no attribute 'get_script_header'
Workaround that fixed it for me: In the list install_requires I had "tornado" before "luigi". By switching the order to "luigi" and then "tornado" this bug went away. I see that you do not use tornado or luigi, but I guess the ordering is still the cause of this problem since you can fix the problem by running your install command twice.
Additional note: Before finding this workaround I tried to upgrade to newest setuptools (v 5.8). It did not solve the bug.
I had the same problem and it was fixed by updating setuptools version, i.e.:
pip install --upgrade setuptools