Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run Processing's Python mode in non-Processing IDEs?

The "Python mode for Processing" file Tutorials/overview/index.html states "Advanced programmers need not use the PDE, and may instead choose to use its libraries with the Python environment of choice."

Unfortunately, it doesn't say how to do this, and I can't find any additional information in their documentation, or on here, or anywhere else.

My environments of choice are the PyCharm Community Edition, and Jupyter notebooks. If it's relevant, I'm on a Mac running OS X 10.11.5 (El Capitan).

Can anyone please tell me what must be done so that I can write and run Python code in those environments, using the "Python mode for Processing" libraries?

like image 990
Andrew Avatar asked Jun 21 '16 15:06

Andrew


2 Answers

It's not really obvious, but you can run Processing sketches through the command line using the processing-py.jar file. Following the tutorial:

  1. Java has to be installed on your system (you can check by running java -version in the terminal).

  2. Download and extract a .tgz file for your system from the link above. Among other files it contains a processing-py.jar file.

  3. Edit your sketch in whatever editor you are used to, and when done just do: java -jar <path to your processing-py.jar file> <path to your sketch file>. This runs your sketch in a new window.

    For convenience you can can copy the jar file (or maybe make a symbolic link with ln -s <source> <target>) to your project directory, so you can just do: java -jar processing-py.jar sketch.py

This approach is editor independent. I don't know much about pycharm, but you can just run your sketches from the pycharm terminal (View -> Tool Windows -> Terminal). I guess there must be a way of executing custom commands in pycharm (for example: builidng sketches in Sublime Text) but I'm not sure how to do it.

like image 90
jjj Avatar answered Sep 22 '22 17:09

jjj


In vscode there is an extension that allows you to run custom terminal commands. You can use it with the processing-py.jar file to run processing.py sketches. There is a tutorial that goes through the process here.

like image 37
Fenjalien Avatar answered Sep 23 '22 17:09

Fenjalien