#Java python interpreter

28 messages · Page 1 of 1 (latest)

winged raptor
#

Hi, (still need help plz)
I want to use java to read python like this for exemple.

package fr.axsc6_l.DiscordBot;
import org.python.util.PythonInterpreter;
public class DiscordBot {
public static void main(String[] args) {
try(PythonInterpreter pyInterp = new PythonInterpreter()) {
pyInterp.exec(
"import asyncio\n" +
"async def hello_world():\n" +
"    await asyncio.sleep(1)\n" +
"    print(\"Hello, World!\")\n" +
"loop = asyncio.get_event_loop()\n" +
"loop.run_until_complete(hello_world())\n" +
"loop.close()");
}}}

BUT Jython (that i'm using here) is not compatible with python 3.10 (only 2.7)

Do you know something that does the same but with python 3.10+
I want something that can run without python installed.
and it need to run on a minecraft server

so:
Jython wrong version of python
JEP need python installed
graalvm not used by the server host

(it's extremely specific)

thx for reading and any advice
have a nice day

rustic cliffBOT
#

This post has been reserved for your question.

Hey @winged raptor! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

whole tiger
#

you could maybe attempt to use GraalPython

#

Also note that it's a big security risk if you allow users execute Python code on your bot

winged raptor
#

it's not realy that

#

it's more like trying to run a python discord bot on a minecraft server

winged raptor
whole tiger
#

However, running GraalPython might require a GraalVM installation instead of a JDK/JRE

winged raptor
#

humm... do you have a tutorial for that?

#

I've downloaded it but IDK how to configure it

whole tiger
winged raptor
#

thx

#

i'll let this open in case i have a question

winged raptor
#

it's so complex to add and manage compared to a lib ;-;

whole tiger
#

but you need to run on GraalVM

winged raptor
#

hum, now that i think about it, will it work on a server (not runing on graalVM)
will it keep it's lib specificity?

whole tiger
#

install GraalVM on the server

winged raptor
#

it's not mine

whole tiger
#

you can provide your application as a docker image

winged raptor
#

how can i do that?

#

it's a minecraft server that i purchased online and that's specificly made for minecraft server

whole tiger
#

ok in a Minecraft server, you can probably not do that

#

theoretically you could make the Java program install Python on startup

winged raptor
#

i'll look for it

#

I may not have admin perm on the server (and no real acces to the computer exept with plugins)

winged raptor
#

what i'm making look so dumb... using java to install python (funny tho)