Guide to Pyjs and Pyjsdl

These notes provide instructions on the use of Pyjs with Pyjsdl, which were tested on Linux and Win7 systems.

Installation of Pyjs 0.8.1-dev is required, currently available from Pyjs Github repository. Check instruction on Pyjs Github site.

The tools required for installation are pip and git, install tools if necessary from package manager (Linux) or follow install instructions on tools Webpage (Win7).
sudo apt-get install python-pip
sudo apt-get install git

Command to install Pyjs with pip:
Linux system install:
sudo pip install git+
Linux local install:
pip install git+ --user
pip install git+

With Pyjs installed, pyjsbuild had error 'pkg_resources.DistributionNotFound: six', resolved after Pyjs install by upgrading Six dependency:
pip show six (upgrade version 1.3 to 1.8)
sudo pip install six --upgrade
easy_install --upgrade six

Command to show information of Pyjs installed by pip:
pip show pyjs
Linux information:
Location: /local/lib/python2.7/site-packages/
Win7 information:
Location: \python27\lib\site-packages

Location of pyjsbuild and pyjscompressor:
Refer to these scripts with system path, instances below are in Linux.

To get HTML5 Canvas to work with IE9+, modify Pyjs as described in pyjsdl/guide.txt:
Use files in to modify or overwrite the following files:
Linux change:
Win7 change:

Use pyjsbuild to compile, check 'pyjsbuild --help' for command options. Use compile options -S (strict mode), -O (optimise mode), and -d (debug). Use of --dynamic-link option links JavaScript files in lib folder, decreasing size of browser specific HTML files and permitting shared lib folder with multiple demo apps. Use the -o option to build to separate output folder for different option set. To test installed Pyjs, compile an app from Pyjs examples, which can be downloaded from Pyjs Github repository. Not all examples work, but tested the following:

Helloworld App
change to folder /examples/helloworld
/local/bin/pyjsbuild -S --dynamic-link -o output

GWTCanvas App
change to folder /examples/gwtcanvas
/local/bin/pyjsbuild -S --dynamic-link -o output

Compile a Pyjsdl demo with Pyjs and Pyjsdl, download demo app and unpack. Download Pyjsdl and unpack, placing Pyjsdl folder in the demo app folder. Compile the script with the command:
/local/bin/pyjsbuild -O --dynamic-link -o output
Following build, place data folder containing images in output folder.
Tested by opening app.html in Firefox, IE, and Chrome.
To open local files, launch Chrome with the option --allow-file-access-from-files
Can use a local server, such as SimpleHTTPServer with command:
python -m SimpleHTTPServer 8000
Server root folder is where command was run, use browser at http://localhost:8000 to browse to HTML file to load.

Use pyjscompressor to compress JavaScript in output folder with command:
python /local/bin/pyjscompressor output
Pyjscompressor uses Closure Compiler, can download latest release and use:
python /local/bin/pyjscompressor output -c compiler.jar
Pyjscompressor did not work in Pyjs build 140806, with 'ImportError: No module named contrib.pyjscompressor', due to missing files apparently left out during installation. Resolved by downloading Pyjs from Pyjs Github repository, and copy missing files from /pyjs/contrib/ to /local/lib/python2.7/site-packages/pyjs/contrib/ (Linux) or \python27\lib\site-packages\pyjs\contrib\ (Win7).

Following compilation with pyjsbuild and optional compression with pyjscompressor, the output folder containing the app can be deployed to a Web server.

This entry was posted in Programming and tagged , , , , . Bookmark the permalink. Trackbacks are closed, but you can post a comment.


  1. Bob
    Posted 2021/03/01 at 21:11 | Permalink

    This worked until i tried to open the html file. It said" serpentduel ImportError: No module named pyjsdl, pyjsdl in context None". How can i fix this?


    • Posted 2021/03/01 at 21:45 | Permalink

      You should make sure you have pyjs installed properly and can compile a program, try to compile and run a pyjs example app such as /examples/helloworld mentioned in this post.


    • Posted 2021/03/01 at 22:25 | Permalink

      Regarding the importerror, the browser reports the error if the demo is pyjs compiled with pyjsdl absent. Ensure the pyjsdl folder is in the demo folder then compile.


      • Bob
        Posted 2021/03/01 at 22:43 | Permalink

        Ok thank you. I had accidently kept the pyjsdl folder inside pyjsdl-0.22. I removed it and the website had loaded, and the starting screen for the serpent duel came up. However, when I click on it, the game does not start.


        • Posted 2021/03/01 at 22:45 | Permalink

          Probably need to move the data folder into the pyjs output folder.


          • Bob
            Posted 2021/03/01 at 22:47 | Permalink

            Oh sorry I forgot. Thank you it works perfectly now.


  2. jee
    Posted 2021/03/27 at 00:53 | Permalink works fine with the instructions above.
    When I try to run my code, it gives me the error, "ImportError: No module named pandas". How do i fix this?


    • Posted 2021/03/27 at 02:29 | Permalink

      I suspect you meant that you got an importerror with pyjamas module that is part of pyjs, seen this error if the script is run with python. The script should be compiled by pyjs to javascript and run in the browser.


  3. Lordofgobgbos
    Posted 2021/03/31 at 17:04 | Permalink

    When I try to run serpentduel, it returns :
    rTaceback (most recent call last):
    File "", line 29, in
    import pyjsdl as pygame #pyjsdl import
    File "/home/lordofgobgobs/Games/pyjsdl/", line 25, in
    from pyjsdl import util
    File "/home/lordofgobgobs/Games/pyjsdl/", line 4, in
    from pyjsdl.time import Time
    File "/home/lordofgobgobs/Games/pyjsdl/", line 6, in
    from __pyjamas__ import JS
    ModuleNotFoundError: No module named '__pyjamas__'


    • Posted 2021/03/31 at 17:28 | Permalink

      Ensure you compiled the script with pyjsbuild and run in the web browser.


      • Lordofgobgobs
        Posted 2021/04/01 at 12:18 | Permalink

        Oh. How do I do that


        • Posted 2021/04/01 at 12:29 | Permalink

          Instructions are in this post and more info on pyjsdl page. The first step is to install pyjs from github as described in this post and then ensure it is functional by compiling and running some pyjs examples. Once everything is working, check guide.txt in pyjsdl package, then should be able to compile the pyjsdl demo.


          • Lordofgobgbos
            Posted 2021/04/01 at 13:18 | Permalink

            Yes, but how do I compile the examples?


          • Posted 2021/04/01 at 13:24 | Permalink

            This guide post has the instruction, install pyjs and then use pyjsbuild to compile, such as:
            pyjsbuild -S


          • Lordofgobgobs
            Posted 2021/04/01 at 14:34 | Permalink

            It always tells me :
            -bash: pyjsbuild: command not found


          • Posted 2021/04/01 at 18:58 | Permalink

            Perhaps provide more info on what you have done. First step is to install pyjs, make sure this is installed from its github repository as this version is required for pyjsdl. Pyjs is still at python2, so you need to install with python2 + pip. This guide post describes the install procedure as well as the location of pyjsbuild after pyjs installation. Further install info is on pyjs github repository page.


Post a Comment

Your email is never published nor shared. Required fields are marked *

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>