You can help by commenting or suggesting your edit directly into the transcript. We'll review any changes before posting them. All comments are completely anonymous. For any comments that need a reply, consider emailing firstname.lastname@example.org.
We are experiencing playback issues from our video hosting provider. Please check back shortly.
Importing Python Libraries
In this lesson, we will learn how to import third party Python libraries into an Ignition container.
Transcript(open in window)
[00:00] In this lesson, I'll demonstrate how to add a third party Python library into a container so that it can be imported into your scripts in Ignition. In my setup, I have a Docker Compose stack with two Ignition gateways, and I really need this "speciallibrary" python code to be able to run in my project to accomplish my project's goals. However, I haven't imported this library yet and my script errors out because the code can't be found. If we recall, we can place Python files in the "pylib" folder in the Ignition install directory in order to import them into Ignition. So, how can we do this with containers? We can accomplish this with bind mounts. I'll head over to my docker compose file and I'll add a new volume to my frontend gateway. I already have a folder that contains my script inside my project folder. All I need to do is add this Python file to the bind mount and I'll mount it to the "pylib" folder in my container, which on Linux is in "usr/local/bin /ignition/userlib/pylib". Now that the mount is set up, I'll save and I can start the container again, and it will apply the changes.
[01:15] I'll reopen my project. reopen the script console and I can paste my code. And now it runs and I can move forward with my project.