PyBox2d and Linux

Hi!
I got surprised of how many Pyweek9 games are using PyBox2d, and i were having huge difficulties on installing on Ubuntu Linux.
What are .egg files from http://code.google.com/p/pybox2d/downloads/list - are they tarballs, .sh, or something else?
Is it only me having problems running these PyBox2d games?

(log in to comment)

Comments

You have to install libbox2d first, then install pybox2d egg.
libbox2d ? where can i find it, and how can i install?
and how can i install pybox2d.egg? where these files must be installed in the filesystem? (seems to be simple making a tarball from them and doing a 'tar -zxvf tarball.tar.gz -C /', but i don't know where to target these files before creating that tarball)
thanks in advance...
the pybox2d page contains some binaries for linux, mac and win:
http://code.google.com/p/pybox2d/downloads/list
2riq: these "binaries" do not contain the actual box2d library.

2nitrofurano: get box2d from the ubuntu repository. If there are no Ubuntu packages, I'm afraid you'll have to download and build it manually. To install egg files just use easy_install, it does all the work for you.
@kent_turbo: among almost 27000 packages Ubuntu has available, there is no box2d... - i'm a bit alergic about building C sources, i'm almost always having problems with it - if someone knows about any .deb , .rpm , tarball or whatever, please let me know... - what is easy_install?
Debian has some packages for libbox2d. easy_install is a tool to download and install eggs easily. It is in the python-setuptools package.
@kent_turbo: do i install all of them? (squeeze or sid) http://packages.debian.org/search?keywords=libbox2d&searchon=names&suite=all&section=all
how do i use easy_install , and how can i install .egg files from it? i have no idea what about is it...

Any tips for OS X would also be appreciated.
OSX: http://pybox2d.googlecode.com/files/Box2D-2.0.2b1-py2.5-macosx10.5.mpkg.zip
Thanks, I somehow expected it to be trickier than that! :)
@kent_turbo: from http://packages.debian.org/search?keywords=libbox2d&searchon=names&suite=all§ion=all i installed those three packages for Debian-Sid because Ubuntu-Jaunty dependencies - i think now i only need to know how easy_install works (is it so 'easy' as is it self-named? :| )
@kent_turbo:
guest@p4:~$ man easy_install
No manual entry for easy_install
See 'man 7 undocumented' for help when manual pages are not available.
guest@p4:~$
nitrofurano: easy_install is part of setuptools (http://pypi.python.org/pypi/setuptools). Once you have that installed you should be able to type 'easy_install box2d' and it will download and install the egg and any dependencies.
@kent_turbo: easy_install looks like everything but easy...

guest@p4:/mnt/sda1/trabalhos/pygame/bibliotecas$ sudo easy_install Box2D-2.0.2b1-py2.5-linux-i686.egg
Processing Box2D-2.0.2b1-py2.5-linux-i686.egg
Removing /usr/local/lib/python2.6/dist-packages/Box2D-2.0.2b1-py2.5-linux-i686.egg
Copying Box2D-2.0.2b1-py2.5-linux-i686.egg to /usr/local/lib/python2.6/dist-packages
Box2D 2.0.2b1 is already the active version in easy-install.pth
Installed /usr/local/lib/python2.6/dist-packages/Box2D-2.0.2b1-py2.5-linux-i686.egg
Processing dependencies for Box2D==2.0.2b1
Searching for Box2D==2.0.2b1
Reading http://pypi.python.org/simple/Box2D/
Reading http://pybox2d.googlecode.com/
Reading http://code.google.com/p/pybox2d/downloads/list
Best match: Box2D 2.0.2b1
Downloading http://pybox2d.googlecode.com/files/Box2D-2.0.2b1.zip
Processing Box2D-2.0.2b1.zip
Running Box2D-2.0.2b1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-_iedCp/Box2D-2.0.2b1/egg-dist-tmp-WS2jkU
Using setuptools.
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
Box2D/Box2D_wrap.cpp:146:20: error: Python.h: No such file or directory
Box2D/Box2D_wrap.cpp:3098:4: error: #error "This python version requires swig to be run with the '-classic' option"
Box2D/Box2D_wrap.cpp:3102:3: error: #error "This python version requires swig to be run with the '-nomodern' option"
Box2D/Box2D_wrap.cpp:3105:3: error: #error "This python version requires swig to be run with the '-nomodernargs' option"
Box2D/Box2D_wrap.cpp:3108:3: error: #error "This python version requires swig to be run with the '-nofastunpack' option"
Box2D/Box2D_wrap.cpp:752: error: expected initializer before ‘*’ token
Box2D/Box2D_wrap.cpp:807: error: expected initializer before ‘*’ token
Box2D/Box2D_wrap.cpp:828: error: expected initializer before ‘*’ token
In file included from /usr/include/c++/4.3/new:45,
                 from /usr/include/c++/4.3/ext/new_allocator.h:37,
                 from /usr/include/c++/4.3/i486-linux-gnu/bits/c++allocator.h:39,
                 from /usr/include/c++/4.3/bits/allocator.h:53,
                 from /usr/include/c++/4.3/string:48,
                 from Box2D/Box2D_wrap.cpp:2517:
/usr/include/c++/4.3/exception:40: error: expected declaration before end of line
error: Setup script exited with error: command 'gcc' failed with exit status 1
guest@p4:/mnt/sda1/trabalhos/pygame/bibliotecas$
@adam - without sudo? i tried with sudo and got error messages as well...

guest@p4:~/Desktop$ sudo easy_install box2d
[sudo] password for guest:
Searching for box2d
Reading http://pypi.python.org/simple/box2d/
Reading http://pybox2d.googlecode.com/
Reading http://code.google.com/p/pybox2d/downloads/list
Best match: Box2D 2.0.2b1
Downloading http://pybox2d.googlecode.com/files/Box2D-2.0.2b1.zip
Processing Box2D-2.0.2b1.zip
Running Box2D-2.0.2b1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-CHjKAB/Box2D-2.0.2b1/egg-dist-tmp-NsLuLE
Using setuptools.
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
Box2D/Box2D_wrap.cpp:146:20: error: Python.h: No such file or directory
Box2D/Box2D_wrap.cpp:3098:4: error: #error "This python version requires swig to be run with the '-classic' option"
Box2D/Box2D_wrap.cpp:3102:3: error: #error "This python version requires swig to be run with the '-nomodern' option"
Box2D/Box2D_wrap.cpp:3105:3: error: #error "This python version requires swig to be run with the '-nomodernargs' option"
Box2D/Box2D_wrap.cpp:3108:3: error: #error "This python version requires swig to be run with the '-nofastunpack' option"
Box2D/Box2D_wrap.cpp:752: error: expected initializer before ‘*’ token
Box2D/Box2D_wrap.cpp:807: error: expected initializer before ‘*’ token
Box2D/Box2D_wrap.cpp:828: error: expected initializer before ‘*’ token
In file included from /usr/include/c++/4.3/new:45,
                 from /usr/include/c++/4.3/ext/new_allocator.h:37,
                 from /usr/include/c++/4.3/i486-linux-gnu/bits/c++allocator.h:39,
                 from /usr/include/c++/4.3/bits/allocator.h:53,
                 from /usr/include/c++/4.3/string:48,
                 from Box2D/Box2D_wrap.cpp:2517:
/usr/include/c++/4.3/exception:40: error: expected declaration before end of line
error: Setup script exited with error: command 'gcc' failed with exit status 1
guest@p4:~/Desktop$
@adam: without sudo:

guest@p4:~/Desktop$ easy_install box2d
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 13] Permission denied: '/usr/local/lib/python2.6/dist-packages/test-easy-install-20710.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /usr/local/lib/python2.6/dist-packages/

Perhaps your account does not have write access to this directory?  If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account.  If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

  http://peak.telecommunity.com/EasyInstall.html

Please make the appropriate changes for your system and try again.

guest@p4:~/Desktop$
If the error is that Python.h is not found, you need to get the package "python-dev", I believe. You should be able to get it from your package manager.
@Cosmologicon - thanks, installed python-dev, and everything else seems to get installed fine now, but:

guest@p4:/mnt/sda1/trabalhos/pygame/recolhas/pyweek/09/30_PyWorld_FlightOfIcarusPyWorldFinal_box2d$ python run_game.py
Traceback (most recent call last):
  File "run_game.py", line 1, in <module>
    import Icarus.main
  File "/mnt/sda1/trabalhos/pygame/recolhas/pyweek/09/30_PyWorld_FlightOfIcarusPyWorldFinal_box2d/Icarus/main.py", line 10, in <module>
    import Box2D
  File "/mnt/sda1/trabalhos/pygame/recolhas/pyweek/09/30_PyWorld_FlightOfIcarusPyWorldFinal_box2d/Box2D/__init__.py", line 23, in <module>
    from Box2D import *
  File "/mnt/sda1/trabalhos/pygame/recolhas/pyweek/09/30_PyWorld_FlightOfIcarusPyWorldFinal_box2d/Box2D/Box2D.py", line 43, in <module>
    _Box2D = swig_import_helper()
  File "/mnt/sda1/trabalhos/pygame/recolhas/pyweek/09/30_PyWorld_FlightOfIcarusPyWorldFinal_box2d/Box2D/Box2D.py", line 41, in swig_import_helper
    if fp is not None: fp.close()
UnboundLocalError: local variable 'fp' referenced before assignment
guest@p4:/mnt/sda1/trabalhos/pygame/recolhas/pyweek/09/30_PyWorld_FlightOfIcarusPyWorldFinal_box2d$

it seems to happen also on all other pybox2d games...
What are .egg files from http://code.google.com/p/pybox2d/downloads/list - are they tarballs, .sh, or something else?

Egg files are a distribution format used by setuptools. If you don't have setuptools installed, you should be able to unzip the egg file (it's just a zip file) and manually move the relevant files into the site-packages folder of your Python installation.

I installed PyBox2D from source, and found that it failed to install a file called Box2D.py. I found it in the source distribution and installed it manually, and things seemed to work after that.
@gcewing - thanks, but i were not used to be that lucky with compiling sources... - i think i did all i could try...  :( - hopefully one day i could install pybox2d just with 'sudo apt-get install', just like i did with pygame... (here is another reason why i'm only using pygame on my own games...)