# GSOC 2019: pyp5js - Enable Python3 with p5.js

**URL:** <https://discourse.processing.org/t/gsoc-2019-pyp5js-enable-python3-with-p5-js/11465>\
**Category:** Summer of Code\
**Created:** [May 21, 2019, 2:35pm UTC](https://discourse.processing.org/t/gsoc-2019-pyp5js-enable-python3-with-p5-js/11465 "2019-05-21T14:35:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![berin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/berin/32/11510_2.png) [@berin](https://discourse.processing.org/u/berin)\
**Post date:** [May 21, 2019, 2:35pm UTC](https://discourse.processing.org/t/gsoc-2019-pyp5js-enable-python3-with-p5-js/11465/1 "2019-05-21T14:35:46Z")

</div>

Hello from Brazil!

Me and Alexandre Villares have been talking for a while about how we could use Python 3 with Processing. Unfortunately, it seems we’re in a dead end when it comes to Processing.py supporting Python 3 because of the Jython’s dependency. Jython doesn’t have a clear roadmap to support Python 3 and [this Stackoverflow’s topic](https://stackoverflow.com/questions/2351008/when-will-jython-support-python-3) has a lot of links covering this issue.

So, we’ve started to think about other strategies and also to research some other Python explorations on integrations with Processing. Our main results were two projects, both from Professor Claudio Esperanca:

- pyprocessing is a pure Python 2 implementation similar to Processing’s API;
- Brythonide provides an online editor to write Python code integrated with p5.js using the Brython project under the hood.

Both of them are incredible projects, but hey didn’t fit our initial requirements. `pyprocessing` is still using Python 2, so it would require the effort of porting it to Python 3. But besides that, there are some API decisions that differs from Processing.py’s one. For us, this was a deal breaker because the sketches we’ve been creating with Processing.py maybe wouldn’t work and, also, we would have to stop using existing Processing’s documentation as our reference.

BrythonIDE, on the other hand, is a very useful tool but it has some drawbacks when it comes to performance. By comparing the frame rate with pure p5.js, we could notice that there’s some slowdowns. But BrythonIDE really opened our ideas to the possibility of integrating Python 3 with p5.js. But it’s definitely worthwhile to take a look at the project’s examples.

Following this path, we’ve started to think about and to develop [pyp5js](https://berinhard.github.io/pyp5js/), a lib to “transcribe” Python 3 code to Javascript code integrated with p5.js. The lib is still under an alpha version, but we’re really excited about the progress so far!

We have some issues listed, but we feel that there’s a major one that would really help newcomers on programming to interact with p5.js using Python. We’d love to be able to encapsulate pyp5js as Processing mode or to create its own “live editor”. The issue covering this discussion is titled [Encapsulate pyp5js as Processing Mode or perhaps as a Mu mode #41](https://github.com/berinhard/pyp5js/issues/41) and feedback or opinions on it would really help us on thinking solutions.

Thanks!

---

<div class="post-metadata">

**Author:** ![abhikpal](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@abhikpal](https://discourse.processing.org/u/abhikpal)\
**Post date:** [June 20, 2019, 8:48am UTC](https://discourse.processing.org/t/gsoc-2019-pyp5js-enable-python3-with-p5-js/11465/2 "2019-06-20T08:48:41Z")

</div>

I had the same issue with Processing.py and started work on a [native Python 3 implementation](https://p5.readthedocs.io/en/latest/) of Processing around two years ago. Most of the development so far has happened during the Google Summer of Code as a project for the Processing Foundation. See the project reports from GSOC [2017](https://abhikpal.github.io/blog/2017/08/27/p5-google-summer-of-code-progress-report), [2018](https://p5.readthedocs.io/en/latest/releasenotes/0.5.0.html) and some details of the [2019](https://summerofcode.withgoogle.com/projects/#6570923275059200) project.

pyp5js certainly looks interesting, however, I had two questions:

1. Is there any special reason you’re transcribing Python code into Javascript?
2. Will users be able to use other Python libraries (say, numpy) with pyp5js?

---

<div class="post-metadata">

**Author:** ![berin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/berin/32/11510_2.png) [@berin](https://discourse.processing.org/u/berin)\
**Post date:** [June 20, 2019, 1:09pm UTC](https://discourse.processing.org/t/gsoc-2019-pyp5js-enable-python3-with-p5-js/11465/3 "2019-06-20T13:09:24Z")

</div>

Hi @abhikpal, thanks for your reply!

I’m familiar with your work with p5 and I’ve already even tested it. I really think it’s a very notable and promising work, although I don’t like with some of the code design decisions because they break existing Python mode sketches (for example the renamed methods from a camel case syntax to a more pythonic way). But, please, keep on with your work because I **really** think it’s very important to the Python community =]

About pyp5js, here are my thoughts:

1 - The reason is that Transcrypt was the best tool I was able to use for the job because of the reasons described in my previous comment. But I also think pyp5js had a different goal than p5py because I wanted to take a step further beyond writing sketches with Python code. My main goal was to share my sketches online with my friends and members of Brazil’s creative coding community. To do so, for now, I need to transcribe it to Javascript code. But I really think that, in a very close future, I won’t need this transcription anymore. More details about this in answer number 2.

2 - In the present, unfortunately, no. We can use only Python libs with JS compatible versions implemented by Transcrypt. But I don’t think pyp5js will rely on Transcrypt forever… There’s a lot of ongoing work on porting Python to the web, including the majority of its scientific stack, under the [pyodide project](https://github.com/iodide-project/pyodide). The project, supported by Mozilla, compiles the CPython to Webassembly giving us the ability to run pure Python code in the browser. I’m following the work closely because it’ll enable pyp5js not only to use all CPython libs, but also to directly manipulate all of the browsers APIs, including the DOM and the Canvas. This will open new paths on rewriting the pyp5js that I’m really interested on exploring.

Thanks,

---

<div class="post-metadata">

**Author:** ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)\
**Post date:** [June 20, 2019, 1:28pm UTC](https://discourse.processing.org/t/gsoc-2019-pyp5js-enable-python3-with-p5-js/11465/4 "2019-06-20T13:28:36Z")

</div>

Out of interest, on the Processing on the JVM front, had you looked at the viability of a [Py4J](https://www.py4j.org/) / [JEP](https://github.com/ninia/jep) like approach, or even [Graal Python](https://github.com/graalvm/graalpython)?

---

<div class="post-metadata">

**Author:** ![berin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/berin/32/11510_2.png) [@berin](https://discourse.processing.org/u/berin)\
**Post date:** [June 20, 2019, 1:50pm UTC](https://discourse.processing.org/t/gsoc-2019-pyp5js-enable-python3-with-p5-js/11465/5 "2019-06-20T13:50:16Z")

</div>

No, I didn’t! Thanks for the links @neilcsmith
