- Posts: 16
- Thank you received: 0
×
Modelio 4.0.0 released (07 Nov 2019)
Modelio 4.0.0 has been released ( www.modelio.org/forum/4-announcements/45...-4-0-0-released.html )
[Solved] Python libraries in scripts
4 years 3 months ago - 4 years 3 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
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
Last Edit: 4 years 3 months ago by chm. Reason: "Solved" marker added.
Please Log in or Create an account to join the conversation.
4 years 3 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
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.
4 years 3 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.
Time to create page: 0.039 seconds