Running python scripts inside a ItelliJ IDEA plugIn
已回答
Hi All,
I am currently integrating a python script into my plug-in project which is developed by Kotlin.
Just wonder if there are any suggestions on this?
Running a python script requires a python interpreter installed. Also, this python script also required to install some python libs ahead (e.g. lark, ninja)
The are two possible ways I can think of:
- Using pyinstaller to pack the script into executables, and run it as an executable file.
- Install all requirements (python interpreter, libs) and run the script.
Not sure if there is any better way to do so.
Any help will be appreciated!
请先登录再写评论。
Hi Wwwpopop! You can add dependency on Python plugin and reuse all this functionality from it. In Python plugin you can configure Python SDK, specify it to a module and install needed packages through our packaging tool.
As an example you can look at a MicroPython plugin implementation https://github.com/JetBrains/intellij-micropython (which works both in PyCharm and Intellij Idea)
Hi Elizabeth,
Thank you! This is really helpful!
Btw, is the Python plugin supported in Android Studio too?
I meant, can I add a dependency on the Python plugin to my Android Studio plugin project?
Yes, Python Community plugin (https://plugins.jetbrains.com/plugin/7322-python-community-edition) is compatible with Android Studio, but, unfortunately, there is a number of issues there: https://youtrack.jetbrains.com/issue/PY-56694/Pycharm-Community-Edition-not-compatible-with-Android-Studio
Thanks Elizabeth!
I am wondering if this approach is suitable for my project, which is a plugin for Android app projects using Java or Kotlin.
After trying this solution, I have some questions.
I am not sure if I should ask them in this thread. If I should have another post for it, let me know. Thanks again.
Hi!
1. Yes, the facet isn't mandatory for interpreter configuration. You still can configure a "Python SDK" and install any necessary packages which are needed
2. Installing Python interpreter isn't supported, but you can request users to configure interpreter which is already installed on their machine.
3. I'm afraid, there is no such document :( You can look into the intellij-community codebase or ask your questions here, in this thread.