check [Solved] Python libraries in scripts

1 year 4 months ago - 1 year 4 months ago #5008 by Iorek
Hi everybody,

Is it possible to import and use within a jthon script libraries that I use in Python? If yes, where should they be located, or how should they be referenced (e.g. env variables...)?
As an example, I have the lxml library within my Python 3.6 installation, and I'd like to use it within a Modelio script.
I tried a simple "from...import..." hoping in the environment variables, but obviously it didn't work.
Is it possible to do so, or does it even make sense?

Thank you,
Francesco

Please Log in or Create an account to join the conversation.

1 year 4 months ago #5016 by ffe
Hi lorek,

In order to use your own Jython library, you must add your libraries directory in the "sys.path" in the Modelio script view.
For example, if your Jython script is the "/home/user/modelio/jythonLib/myLib.py" file:

sys.path.append( os.path.join ("home", "user", "modelio", "jythonLib"))
import myLib

Hope this helps,
ffe
The following user(s) said Thank You: Iorek

Please Log in or Create an account to join the conversation.

1 year 4 months ago #5017 by Iorek
Thank you, ffe, I tried right now and it worked fine!

Please Log in or Create an account to join the conversation.

Moderators: chmcma
Time to create page: 0.039 seconds
^ Back to Top