playing around with py2app - python

I was playing around with py2app on Snow Leopard(10.6) and I'm running into a few problems when I run
python setup.py py2app
I get the following error :-
% python setup.py py2app
running py2app
Traceback (most recent call last):
File "setup.py", line 18, in <module>
setup_requires=['py2app'],
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/core.py", line 152, in setup
dist.run_commands()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/dist.py", line 975, in run_commands
self.run_command(cmd)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/dist.py", line 995, in run_command
cmd_obj.run()
File "/Library/Python/2.6/site-packages/py2app-0.7.3-py2.6.egg/py2app/build_app.py", line 502, in run
if sysconfig.get_config_var('PYTHONFRAMEWORK') is None:
AttributeError: 'NoneType' object has no attribute 'get_config_var'
I had installed py2app as per the documentation here, however it seems there are a few environment variables that I haven't set. I also tried cloning a few projects, like the one here and I end up with the same error.
Could someone point me to the documentation that mentioned how I'm supposed to configure py2app before use? Thanks.

That py2app documentation is ancient; what you should be using is here.
As you can see from the stack trace you pasted, something is causing distutils.sysconfig to be None. It looks like you're using the system versions of Python and distutils, which work just fine for me on 10.6.8:
% /usr/bin/python -c "from distutils import sysconfig; print sysconfig.get_config_var('PYTHONFRAMEWORK')"
Python
So if you get a different result from above, you could start there, otherwise you can start debugging the py2app code to see why sysconfig is None.

It is a bug in py2app, a quick workaround: in build_app.py (see the traceback in the question for its location) at line 25 change "sysconfig = None" to "from distutils import sysconfig".
I've filed an issue in py2app's tracker[1] and will do a new release soonish (once I've had time to create and test a patch).
[1] https://bitbucket.org/ronaldoussoren/py2app/issue/96/py2app-doesnt-work-with-python-26-anymore

Related

How to use esky on windows with python 3.4?

I'm trying to package an auto updating python 3 application using esky, but cannot get it to work on windows.
I'm trying to get the simplest example from the tutorial to work.
https://github.com/cloudmatrix/esky/tree/master/tutorial/stage1
My environment:
Z:\share_space\esky-master\tutorial\stage1>python --version
Python 3.4.3
Z:\share_space\esky-master\tutorial\stage1>pip freeze
...
cx-Freeze==4.3.4
esky==0.9.8
py2exe==0.9.2.2
...
When run using py2exe as the freezer, it fails to find the py2exe module for some reason (though freezing other apps with "python setup.py py2exe" works just fine).
Z:\share_space\esky-master\tutorial\stage1>python setup.py bdist_esky
running bdist_esky
Traceback (most recent call last):
File "setup.py", line 17, in <module>
"freezer_module":"py2exe",
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 973, in run_command
cmd_obj.ensure_finalized()
File "C:\Python34\lib\distutils\cmd.py", line 107, in ensure_finalized
self.finalize_options()
File "C:\Python34\lib\site-packages\esky\bdist_esky\__init__.py", line 291, in
finalize_options
raise RuntimeError(err)
RuntimeError: freezer module not found: 'py2exe'
With cx-Freeze building the package works well but running the executable fails.
Z:\share_space\esky-master\tutorial\stage1>dist\example-app-0.1.win32\example.ex
e
ValueError: bad marshal data (unknown type code)
Fatal Python error: unable to locate initialization module
Current thread 0x00001254 (most recent call first):
In order got get a working windows build you need the following:
The latest esky version from github (not pypi).
To circumvent an esky bug ensure the character case of dependencies listed with pip freeze are correct and reinstall if not.
I can confirm using cx-Freeze works (py2exe not tested yet).
See this github issue as to how the problem was resolved.

pyjamas - pyjsbuild error due to DistributionNotFound

I am trying to build the HelloWorld example page from the Pyjamas example folder. However I am receiving this error when I run: sudo pyjsbuild helloworld.py. This error seems pretty universal to python as it seems to be related to the setup/configuration of my python environment. Any advice on where to look for the problem?
Here is the error
Traceback (most recent call last):
File "/usr/local/bin/pyjsbuild", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: six
After trying the various answers, it turns out pip was not properly installing the six package, whatever that is. So I ran sudo easy_install pip (--upgrade) to make sure the script configuration was right. It wrote some extra files so I assume that's why my next command sudo pip install six or sudo pip install six --upgrade worked. Now I ran into another error -_-, For anyone looking later: Runtime Error: Top module not found 'hello world'
Edit: The top module error is coming from trying to build into the output folder that is not pyjs/. All I had to do was move the folder up to pyjs/ folder in sitepackages/.

Upgrading py2app with pip breakes it

I upgraded py2app (using pip) and then ran
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/bin/py2applet --make-setup --arch=i386 test.py
However I get the following
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/bin/py2applet", line 5, in <module>
from pkg_resources import load_entry_point
File "/Library/Python/2.7/site-packages/pkg_resources.py", line 2797, in <module>
parse_requirements(__requires__), Environment()
File "/Library/Python/2.7/site-packages/pkg_resources.py", line 576, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: py2app==0.6.3
I don't want to use 0.6.3 why is it forcing me to?
It looks like the py2applet shell script has an explicit exit call that checks the py2app version. Updating it to the latest seemed to do the trick. I have two parallel installs of python, the native OS X one and one from MacPorts. Somehow the py2applet script wasn't taken into account after updating the port. I wouldn't recommend this method for other distributions but on a Mac this seems to me a viable solution.
#!/usr/bin/python
__requires__ = 'py2app==0.8'
import sys
from pkg_resources import load_entry_point
sys.exit(
load_entry_point('py2app==0.8', 'console_scripts', 'py2applet')()
)
By the way you can find the version number by importing py2app in the python shell:
python
import py2app
py2app.__version__
Gives me:
'0.8'

Python SQLite Wrapper apsw-3.7.16.2 failed to install in mac os x (10.7.5)

Failed to install sqlite wrapper. Any help with installation will be really helpful.
Downloaded from
Installed sqlite3.version
'2.6.0'
Please find the error log below-
sudo python setup.py install test
running install
running build
running build_ext
SQLite: Using system sqlite include/libraries
running install_lib
running install_egg_info
Removing /Library/Python/2.7/site-packages/apsw-3.7.16.2_r1-py2.7.egg-info
Writing /Library/Python/2.7/site-packages/apsw-3.7.16.2_r1-py2.7.egg-info
running test
Traceback (most recent call last):
File "setup.py", line 857, in <module>
'win64hackvars': win64hackvars}
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "setup.py", line 102, in run
import tests
File "/Users/tj/Downloads/apsw-3.7.16.2-r1/tests.py", line 9, in <module>
import apsw
ImportError: dlopen(/Users/tj/Downloads/apsw-3.7.16.2-r1/apsw.so, 2): Symbol not found: _sqlite3_db_filename
Referenced from: /Users/tj/Downloads/apsw-3.7.16.2-r1/apsw.so
Expected in: flat namespace
in /Users/tj/Downloads/apsw-3.7.16.2-r1/apsw.so
It is picking up the system SQLite shared library which is an older version. MacOS tends to ignore the SQLite library you want it to use and force using a known system one. (Many OS components like CoreData depend on SQLite which is why they like to force using a known good version.)
The easiest fix is to use the command line as specified in the documentation. It ensures a private copy of SQLite is embedded in the extension and hence will always work.
http://apidoc.apsw.googlecode.com/hg/build.html#recommended
python setup.py fetch --all build --enable-all-extensions install test
(I'm the APSW author). BTW there is a python-sqlite mailing list which you may find useful.

Howto install distribute for Python 3

I am trying to install distribute using ActivePython 3.1.2 on Windows.
Running python distribute_setup.py as described on the cheese shop give me:
No setuptools distribution found
running install
Traceback (most recent call last):
File "setup.py", line 177, in
scripts = scripts,
File "C:\Dev\Python_x86\3.1\lib\distutils\core.py", line 149, in setup
dist.run_commands()
File "C:\Dev\Python_x86\3.1\lib\distutils\dist.py", line 919, in run_commands
self.run_command(cmd)
File "C:\Dev\Python_x86\3.1\lib\distutils\dist.py", line 938, in run_command
cmd_obj.run()
File "build\src\setuptools\command\install.py", line 73, in run
self.do_egg_install()
File "build\src\setuptools\command\install.py", line 82, in do_egg_install
easy_install = self.distribution.get_command_class('easy_install')
File "build\src\setuptools\dist.py", line 361, in get_command_class
self.cmdclass[command] = cmdclass = ep.load()
File "build\src\pkg_resources.py", line 1953, in load
entry = import(self.module_name, globals(),globals(), ['name'])
File "build\src\setuptools\command\easy_install.py", line 16, in
from setuptools.sandbox import run_setup
File "build\src\setuptools\sandbox.py", line 164, in
fromlist=['name']).file)
AttributeError: 'module' object has no attribute 'file'
Something went wrong during the installation.
See the error message above.
Is there possibly an unknown dependency that I'm missing?
Downloading the source tarball and executing python setup.py install produces the exact same output.
Edit: Added the full stack trace for running the installer.
So apparently the python.org version of Python3 is different from the ActiveState version of Python3. (You should file a bug to someone (I'm not sure to whom))
The fix I have (I'm not sure of all the repercussions)
Download:
http://pypi.python.org/packages/source/d/distribute/distribute-0.6.12.tar.gz#md5=5a52e961f8d8799d243fe8220f9d760e
and then extracting it and modify:
distribute-0.6.12\setuptools\sandbox.py:165
from:
except ImportError:
to
except (ImportError, AttributeError):
that will silence the error and allow you to run:
python setup.py install
It took me awhile to find a package from http://pypi.python.org/pypi?:action=browse&c=533&show=all that would actually install on either version of Python3. "files" was the first package, and since it installed I am pretty sure that easy_install is working for both copies of Python3.
...hope it works! (That's all I can help you with)
this is a bug with Distribute http://bitbucket.org/tarek/distribute/issue/151 ... it should be fixed by next release (0.6.13). It is only reproducible with PyWin32 installed; and ActivePython comes bundled with PyWin32.

Categories