0

I am trying to make some utils for a Python script that run using Jython 2.7.0 (I could update if needed)

My current problem is pretty simple, i can't import/use my module For a bit of context, my python script is run by the Jython-standalone jar, as a Minecraft mod, so its kinda annoying to even get it to detect the modules

When I first tried to import my module, by putting them all in the same folder, I couldn't import them, so I did:

import sys

sys.path.append("C:\Users\<myUser>\Desktop\BotUHC+")

import UHCGame #My Module i want to import

def interact(e):
    UHCGame.setupBaseGame(e)

Now, my module doesn't send back any "ImportError module not found", but I can't call that function from UHCGame, because i get the error:

javax.script.ScriptException: AttributeError: 'module' object has no attribute 'setupBaseGame' in <script> at line number 9

Despite it being present in the UHCGame.py file, even VSCode auto completion can detect it.

I wandered inside Jython's docs, and found out that it needs to compile some class before importing them, and for some reason, mine wasn't compiled, so i manually compiled it, and still got the same result.

For more info:

  • The script that is run "TestFile.py", is in -> .minecraft/saves/world/customnpc/script/python/
  • The module is in "C:\Users<myUser>\Desktop\BotUHC+", as for the compiled version of it
2
  • Try moving your BotUHC to .minecraft/saves/world/customnpc/script/python/ and drop the sys.path.append statement Commented Oct 6, 2023 at 13:18
  • Another thing... Do you have a __init__.py file in the package folder? Try to update the question with a simple scheme of the directory structure of the BotUHC package Commented Oct 6, 2023 at 13:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.