What you're changing and why it matters

PyScripter uses a file called __init__.py to set up its Python environment when it starts. The Python path — the list of directories PyScripter searches for modules and packages — lives partly in this file. If PyScripter can't find your installed packages or you want it to use a different Python installation, editing the path in __init__.py is often the solution.

The __init__.py file sits in PyScripter's own folder structure, not in your Python installation. Changing it tells PyScripter exactly where to look for Python libraries, which is different from changing your system's Python path or your user environment variables.

Key Takeaways

  • PyScripter's __init__.py file is located in the PyScripter installation folder, typically under Lib\site-packages\pyscripter on Windows.
  • You edit __init__.py with a plain text editor to add directories to sys.path, which tells PyScripter where to find Python modules.
  • Adding a line like sys.path.insert(0, 'C:\\your\\custom\\path') makes PyScripter search that directory first for packages.
  • After editing __init__.py, restart PyScripter completely for the changes to take effect.
  • If you're unsure whether to edit __init__.py or use environment variables, check PyScripter's Tools menu first — it often has a Python Path option that's easier to use.

Finding the __init__.py file on your computer

The location of __init__.py depends on how you installed PyScripter. On Windows with a standard pip installation, look in C:\Users\[YourUsername]\AppData\Local\Programs\Python\Python[Version]\Lib\site-packages\pyscripter. On macOS or Linux, it's usually in /usr/local/lib/python[version]/site-packages/pyscripter or ~/.local/lib/python[version]/site-packages/pyscripter.

If you installed PyScripter from a standalone executable or portable version, the file may be in a different location entirely — check your installation folder directly. You can also open PyScripter, go to Tools > Options > Interpreter, and look for a path display that shows where PyScripter is running from.

Once you've found the folder, open it in File Explorer or your system's file manager. You should see __init__.py listed among other Python files. If you don't see it, make sure you have "Show hidden files" enabled in your file manager's view settings.

Opening and editing the file safely

Right-click on __init__.py and choose Open with, then select a plain text editor like Notepad (Windows), TextEdit (macOS), or gedit (Linux). Do not use Microsoft Word or any rich-text editor — they add formatting that will break the file. If you have a code editor installed like Visual Studio Code or Sublime Text, those work well too.

Before you make any changes, create a backup copy of __init__.py in the same folder. Right-click the file, select Copy, then Paste in the same location. Rename the copy to something like __init__.py.backup. If something goes wrong, you can restore the original.

Open the file in your text editor. You'll see Python code that sets up PyScripter's environment. Look for lines that mention sys.path — this is the list PyScripter searches for modules. This is where you'll add your custom paths.

Adding a custom path to sys.path

Find a line in __init__.py that already uses sys.path, or add one near the top of the file after the import statements. A typical addition looks like this:

sys.path.insert(0, 'C:\\Users\\YourName\\MyPythonLibraries')

Replace C:\\Users\\YourName\\MyPythonLibraries with the actual path to your folder. Use forward slashes / instead of backslashes on macOS and Linux, or use raw strings with r prefix on Windows: sys.path.insert(0, r'C:\Users\YourName\MyPythonLibraries').

The insert(0, ...) part tells PyScripter to search this directory first, before any others. If you want it to search after the default paths instead, use sys.path.append(...) instead of insert(0, ...). You can add multiple paths by repeating the line with different directories.

If you want to add the path to your main Python installation's site-packages folder, find where Python stores packages on your system. Open a terminal or command prompt and type python -c "import site; print(site.getsitepackages())" to see the exact path, then add that path to __init__.py the same way.

Saving and testing your changes

After you've added your paths, save the file. Use File > Save or press Ctrl+S (Cmd+S on macOS). Make sure the file is still named __init__.py with no extra extension like .txt — if your editor added one, rename it back.

Close PyScripter completely — not just minimize it, but fully exit the program. Then restart PyScripter. The new paths in __init__.py will load when it starts up.

To test whether your changes worked, open PyScripter's Python console (usually View > Python Console) and type import sys followed by print(sys.path). You should see your custom path listed in the output. Try importing a module from that directory to confirm PyScripter can find it.

When to use PyScripter's built-in path tool instead

Before editing __init__.py directly, check whether PyScripter has a simpler option. Open Tools > Options and look for Interpreter or Python Path. Many versions of PyScripter include a dialog where you can add paths without touching any files — this is safer and easier than manual editing.

If that option exists in your version, use it. The built-in tool handles the technical details for you and is less likely to cause problems. Only edit __init__.py directly if PyScripter doesn't have this feature or if the built-in tool doesn't solve your problem.

You should also check whether your issue is actually a path problem. If PyScripter can't find a package, the problem might be that the package isn't installed at all, or that you're using the wrong Python version. Try running pip list in a terminal to see what's actually installed, and make sure PyScripter is using the same Python version you installed packages into.

Troubleshooting common problems

If PyScripter still can't find your modules after editing __init__.py, check that you used the correct path. Paths are case-sensitive on macOS and Linux. Also make sure the folder actually exists — if you typed the path wrong, PyScripter will silently ignore it and move on.

If PyScripter won't start at all after your edit, you probably introduced a syntax error in the Python code. Close PyScripter, restore your backup copy of __init__.py, and try again more carefully. Common mistakes include forgetting quotes around the path, using backslashes without escaping them, or leaving out a comma or parenthesis.

If you see an error message when PyScripter starts, read it carefully — it usually points to the line number where the problem is. Open __init__.py again and check that line. If you're stuck, you can always restore the backup and use PyScripter's built-in path tool instead.

Frequently Asked Questions

Do I need to edit __init__.py or can I just change my system's Python path?

You can do either. Changing your system's Python path affects all Python programs on your computer. Editing PyScripter's __init__.py affects only PyScripter. If you want the change to apply everywhere, use your system's environment variables. If you want it to apply only to PyScripter, edit __init__.py.

What's the difference between sys.path.insert and sys.path.append?

insert(0, ...) adds your path to the front of the search list, so PyScripter checks it first. append(...) adds it to the end, so PyScripter checks it last. Use insert if you want your custom modules to override the default ones with the same name. Use append if you want the defaults to take priority.

Will editing __init__.py affect other Python programs on my computer?

No. The __init__.py file is specific to PyScripter. Other Python programs won't see the changes you make to it. If you want to change the path for all Python programs, you need to set environment variables or edit the system Python path instead.

Can I add a path that doesn't exist yet?

You can add the line, but PyScripter will ignore the path if the folder doesn't exist. Make sure the directory actually exists on your computer before you add it to __init__.py. If you plan to create the folder later, you can add the path now, but PyScripter won't find anything in it until the folder is created.

What if I want to remove a path I added?

Open __init__.py again, find the line you added, and delete it. Save the file and restart PyScripter. The path will no longer be searched. If you're not sure which line to delete, restore your backup copy and start over.