2 - py-dss-toolkit | Environment Setup: Configure Python for py-dss-toolkit

🎯 Objective

Guide students through configuring a Python project in PyCharm and installing the py-dss-interface and py-dss-toolkit packages so they can control OpenDSS from Python.


🧠 Key Concepts

  • virtual environment setup in PyCharm

  • installing py-dss-interface

  • installing py-dss-toolkit and dependencies

  • verifying imports and package versions

  • integrating Python with OpenDSS


📜 Transcript Summary

In this environment-setup tutorial Paulo Radatz walks through creating a Python project in PyCharm, selecting a Python interpreter (e.g., 3.11), and using a project-local virtual environment to install the py-dss-interface and py-dss-toolkit packages. He demonstrates creating a Python file, installing packages via pip, confirming imports run without errors, and checking installed versions (py-dss-interface 2.1.1 and py-dss-toolkit 0.3.0) with pip list. The video emphasizes reproducibility (use of a venv), flexibility in Python/IDE versions, and points learners to additional resources and a course on pauloradatz.me.

Topics: distribution systems, OpenDSS, and Python.


💬 Suggested LLM Prompts

  • How do I configure a PyCharm project to use a project-local virtual environment and ensure PyCharm uses that interpreter?

  • I installed py-dss-interface but get 'No module named' when importing — what are the common causes and how do I fix them?

  • What are the differences between py-dss-interface and py-dss-toolkit, and when should I install each one for OpenDSS workflows?


📖 Table of Contents

  • Introduction and goals

  • Prerequisites (OpenDSS, Python, PyCharm)

  • Creating a new PyCharm project

  • Selecting Python interpreter and creating venv

  • Verifying the virtual environment

  • Creating the initial Python file

  • Installing py-dss-interface

  • Installing py-dss-toolkit and dependencies

  • Importing packages and running a test

  • Checking installed package versions with pip list

  • Resources, course mention, and closing


📚 Glossary

  • virtual environment: A project-local Python interpreter and package directory that isolates dependencies from the system Python.

  • OpenDSS: An open-source electric power Distribution System Simulator.

  • py-dss-interface: A lightweight Python package that provides a programmatic interface to control OpenDSS from Python.

  • py-dss-toolkit: A higher-level Python package that bundles utilities and common dependencies (NumPy, Matplotlib, etc.) to facilitate analysis and workflows with OpenDSS.

  • pip: The Python package installer used to download and install packages from PyPI into the active Python environment.


🐍 Python Code Examples

import py_dss_interface

import py_dss_toolkit

🕒 Full Transcript

Introduction (00:00:00)

Hi everyone, it's Paulo Radatz, and this is the second video of our py-dss-toolkit tutorial. In this video, we're going to cover how to create our Python project using PyCharm to control OpenDSS. So we make sure that you guys can follow along the tutorial. But before we start, I would appreciate, guys, if you can subscribe to my channel. Only 40% of you are subscribed, so I would appreciate it. Thanks so much for doing that.

Requirements and Assumptions (00:00:35)

Now, what I'm going to do here, I assume you have OpenDSS installed in your computer. I assume you have a version of Python installed in your computer, maybe 3.11, 12, 13, whatever is available there. And also that you have a PyCharm version in your computer, so you can actually follow along exactly what I do. Now, if you have a different Python version, no problem. If you like to use another IDE, not PyCharm, no problem as well. So I think the content and the knowledge that I'm sharing here, you can get that using different tools. But if you want to replicate everything I do, then I recommend you guys to have the same thing I have.

Creating the PyCharm Project (00:01:17)

Okay, so with that said, I'm going to go here and open my PyCharm. So I have my PyCharm on my computer, and in here I'm going to create a new project. When I do that, I'm going to find a folder that I have my project, it's C, in my case, right? And then follow that, and then py-dss-toolkit Tutorial. This is the folder that I will create my Python project. Okay, when I do that, here I can select a different version of Python that I can use. You can even look for other versions here if you want to. But in this case, let's use the one I have, which is 3.11. I know we now have 3.13, you can use that as well, no problem. All right, I'm going to use 3.11. And then here, this is the settings. When you do that, it's going to create an interface like that, okay?

Virtual Environment and Interpreter (00:02:15)

And then it creates for you a folder called .venv. This is the virtual environment. So this is a folder that hosts a Python interpreter, okay? It's a local one in this folder. So the packages that we install, that we're going to use, will live here, not in your base Python, okay? All right, with that said, I can come here in the terminal and make sure I see .venv here. And then that's what I need to see. So very good. I can also come here and go settings, and then I go to project, Python interpreter, and it's going to tell me the interpreter. You can even get the address here if you want to, to make sure it's where we should go, which is exactly this folder. If for some reason PyCharm doesn't do it automatically for you, you could come here and add the interpreter yourself, right? But again, we already have it. If you have questions, problems, leave in the description below so I can help you further. Amazing.

Creating a Python File and Importing Packages (00:03:28)

All right, so with that said, what I'm going to do, I'm going to first create a Python file. So Python file, and I'm going to call it maybe 0, maybe 1, setting up, okay? Okay? All right. Very nice. So here now I'm going to import the packages I need. So we're going to make sure it works. So if I come here and try to import py-dss-interface, right? This is a package that we need to have, and I'll show you one thing in a second. You can see that it's going to tell me there's no module name. It's because we didn't install it.

Installing py-dss-interface (00:04:26)

So you need to come here in your terminal. Again, let me close it. Just make sure we start again. And then I'm going to type pip install py-dss-interface. Okay? So now it goes online and downloads it. So right now we have the latest version 2.1.1. Let me open here for you guys. So I can come here and then py-dss-interface, PyPI. Let's see if that finds easy. Yes, it's here. For some reason. Okay, gotcha. So here is the latest version we have, 2.1.1. Here's the description of the tool. You also can go to the source code, the GitHub, somewhere here. Here, source. Okay, so you can go there in the source. And this is the repository.

Resources and Course (00:05:20)

One thing I want to mention here, and I'm probably going to mention in most of the videos. If you go to my website, pauloradatz.me, I'll leave the link down below. There is courses that I'm providing, and one of them is about py-dss-interface. So I can click here. This is a very good resource if you want to really understand how to control OpenDSS and using py-dss-interface. There are nine modules that I cover from the basics, and then exploring, you know, exploring, manipulating properties, results, creating algorithms, and also debugging and troubleshooting. So very, very good, very good material. So you can, I'll leave the link below if you want to, you know, follow that course. Again, okay, that's just one thing I want to mention here.

Installing py-dss-toolkit (00:06:33)

Back to where we were in our PyCharm. So here we install py-dss-interface. Now what I can do, import py-dss-interface. Okay, now I have it. Okay, very nice. The other package that we need is really the toolkit. So we're going to do pip install py-dss-toolkit. Oops, all right, toolkit. Yes, let's see. Yeah, it's downloading. Now it downloads more things, right? So py-dss-interface is meant to be very light. There's no 3rd-party packages. It's just Python per Python that talks to OpenDSS. Now py-dss-toolkit is meant to really give us capabilities. So we need to use bundles. We need to use whatever Matplotlib here, what else we have here. The other package is NumPy. That's going to help us really leverage Python packages to work with OpenDSS.

Verifying Installation (00:07:28)

Now we can come here and say import py-dss-toolkit, right? So here we now have the two packages. I'm importing py-dss-interface and importing py-dss-toolkit. You can right-click here and then run it. So when you do that, you're going to see that the process finished with exit code zero, meaning it worked. So we have those two packages in my virtual environment, and that's what you need to see when you run this code. So if that's what you see, we are ready to go and start the other videos. Now if you have problems, you can use the comments below so I can help you. But let's go to the terminal and then do like pip list, right? Pip list is going to show me all the packages I have now. So I have all the dependencies. But here, as you can see, py-dss-interface 2.1.1 and py-dss-toolkit 0.3.0. So those are the packages we need. And like I said, if you run this code and you see this message, then we are ready to go to the next video.

Closing (00:08:45)

So thanks so much, guys, for being here with me. Don't forget to subscribe to my channel. Leave the thumbs up. And if you have any questions, any suggestions, please leave in the comment section below. Thanks so much and see you in the next video.

Be first to know.

Get an email when I publish new tutorials, videos, and code examples.