2012-02-15

Installing Python Pyjamas and Pyjamas desktop for Windows 7

I am testing out python pyjamas as a gui front end which I can scale from a desktop app to web app to cloud deployable scalable app with very little change.  I have tried a number of different GUI stacks, the last was pytgtk which only worked with 32 bit Python which I had to install on top of my 64 bit python.  To start I have gone back to 64 bit python.

Going to the pyjamas wiki getting started  I started using the windows help.  I noticed it was a little out of date so decided to write my experience here.  I have already got a working version of Python 2.72 64 bit on Windows.

Next I installed tortoiseGIT as I have used TortoiseSVN a lot.  I also needed to install the Windows GIT client which I should have done first.  Then I create a pyjamas directory in my download directory and use right click Git clone to create the directory.

gitClone

You need to change the URL to git://pyjs.org/git/pyjamas.git and press OK.

gitCloneDialogBox

The first time I did it it failed so I deleted everything and tried again and this time it worked.

I then installed comtypes which was version 0.6.2.  I had two versions of Python installed so I selected Python 2.7.  It then had an error at then end:

ComtypesError


Carrying on, assuming that GTK may not be needed as Pyjamas desktop is using MSHTML and for my desktop I am at the moment only worried about desktop Windows apps. (I really don’t want to go back to Python 32bit again) I copied the pyjamas directory to my C drive so that I had the following directory C:\pyjamas\pyjd

I updated the system path  ControlPanel->System->Advanced system settings->(Advanced Tab)Environment Variables->Edit path  I added C:\python27;C:\pyjamas\bin. Note the pyjamas bin directory is added in the next step:

Open up a command window and then run which will create the bin directory:

cd \pyjamas
python bootstrap.py

I then created a build.bat in the helloworld directory:

pyjsbuild.bat --print-statements Hello

and also a run file:

pyjd Hello.py

Pyjamas works by combining files from the public directory eg files and template html and your code.  In order to use either the output or the desktop you must run the build process first.  Then you can use the run file first the app just opened up  in a new windowSmile and worked:

helloworld

If I opened the browser with output\hello.html I just got the static text but need to change to the output directory and run the html file (so the default location of other files works) then I get the application in a browser window.  I was using by default IE and didn’t work on getting the others to work.  This from start to end took me about 3 hours including writing my notes as I went.

4 comments:

Joaquin Abian said...

Thanks for the recipe.
I used it with pyjamas 0.8 alpha 1 (using the targz package) and could not made it work. when running run.bat (for the Hello example) it says that pyjd is an unknown application. boostrap created the bin directory with pyjsbuild and pyjampiler files but there is not any pyjd file there as I would expect. Where pyjd should be found ?

RubyPane said...

On my system pyjd.bat is in C:\pyjamas\bin. I had to modify my path to put this directory into it.

RPMSblog said...

Hi. I was glad to see your post as it's tough to get windows help for pyjs I am finding.

Can you please let me know of any other details about the comtypes install? I just get "No Python installation found in the registry"
on both a desktop and a laptop. I have added both python and pyjs to the windows $env:path as C:\Python27;C:\Pyjamas\bin .

Out of clues .. thanks for any help!

Mo said...

To answer the above question, you have to install python only for yourself and not for all users (it's an option in the python installer). I have no idea why this works, but it seems to do the job.