简体   繁体   English

如何在非处理IDE中运行处理的Python模式?

[英]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." Tutorials / overview / index.html文件的“用于处理的Python模式”指出“高级程序员无需使用PDE,而是可以选择将其库与所选的Python环境一起使用。”

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. 我选择的环境是PyCharm Community Edition和Jupyter笔记本。 If it's relevant, I'm on a Mac running OS X 10.11.5 (El Capitan). 如果相关,我在运行OS X 10.11.5(El Capitan)的Mac上。

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? 谁能告诉我必须做什么,以便我可以使用“处理的Python模式”库在那些环境中编写和运行Python代码?

It's not really obvious, but you can run Processing sketches through the command line using the processing-py.jar file. 并不是很明显,但是您可以使用processing-py.jar文件通过命令行运行“处理”草图。 Following the tutorial : 按照教程进行

  1. Java has to be installed on your system (you can check by running java -version in the terminal). 必须在系统上安装Java(可以在终端中运行java -version进行检查)。

  2. Download and extract a .tgz file for your system from the link above. 从上面的链接下载并提取适用于您系统的.tgz文件。 Among other files it contains a processing-py.jar file. 除其他文件外,它还包含一个processing-py.jar文件。

  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> . 在您习惯使用的任何编辑器中编辑草图,完成后只需执行以下操作: 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 为了方便起见,您可以将jar文件(或者可以使用ln -s <source> <target>进行符号链接)复制到项目目录,因此您可以执行以下操作: 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 ). 我对pycharm不太了解,但是您可以从pycharm终端( 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. 我猜必须有一种在pycharm中执行自定义命令的方法(例如: Sublime Text中的builidng草图 ),但我不确定如何执行。

In vscode there is an extension that allows you to run custom terminal commands. 在vscode中,有一个扩展允许您运行自定义终端命令。 You can use it with the processing-py.jar file to run processing.py sketches. 您可以将其与processing-py.jar文件一起使用以运行processing.py草图。 There is a tutorial that goes through the process here . 还有的是通过处理进行的教程在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM