What the Python path does and why you might need to change it

The Python path is the list of directories your computer searches when you run a Python script or import a module. PyScripter, a lightweight Python IDE, reads this path from a file called __init__.py in its configuration folder. If PyScripter cannot find your Python libraries or custom modules, the problem is usually that the path does not include the directory where those files live.

You change the Python path in PyScripter's __init__.py file by adding or editing lines that tell Python where to look. This is different from changing your system-wide Python path — you are only changing what PyScripter sees when it runs scripts inside the IDE.

The most common reason to do this: you have installed a Python package in a non-standard location, or you have written your own modules in a folder that PyScripter does not know about yet.

Key Takeaways

  • PyScripter's __init__.py file lives in the PyScripter installation folder, usually C:\Program Files\PyScripter on Windows or /Applications/PyScripter on macOS.
  • You add directories to the Python path by opening __init__.py in a text editor and adding lines like sys.path.append('C:\\your\\folder\\path') before any import statements.
  • The path must point to the exact folder where your modules or packages live, not to a parent folder or a subfolder.
  • After you save __init__.py, close and reopen PyScripter completely for the changes to take effect.
  • If you make a syntax error in __init__.py, PyScripter will fail to start — keep a backup of the original file.

Finding your PyScripter installation folder

Before you can edit __init__.py, you need to know where PyScripter is installed on your computer. On Windows, open File Explorer and navigate to C:\Program Files or C:\Program Files (x86) and look for a folder named PyScripter. On macOS, open Finder, go to Applications, and look for PyScripter.

If you installed PyScripter in a custom location, you can find it by opening PyScripter itself, clicking the menu bar, and looking for a Help or About section that shows the installation path. Some versions display this information in the startup window.

Once you have found the folder, look inside for a file named __init__.py. If you do not see it, the file may be hidden. On Windows, open File Explorer, click View, and check the box for "Hidden items". On macOS, press Command+Shift+Period to show hidden files.

Opening and editing the __init__.py file safely

Before you make any changes, make a copy of __init__.py and save it with a different name, like __init__.py.backup. This way, if something goes wrong, you can restore the original file and PyScripter will start again.

Open __init__.py with a plain text editor — Notepad on Windows, TextEdit on macOS (set to plain text mode), or any code editor you have. Do not use Microsoft Word or any word processor, because they add formatting that will break the file.

Look at the top of the file. You will see lines that start with import or import sys. These are the imports. You need to add your path changes after the imports but before any other code that uses those paths.

Adding a directory to your Python path

To add a directory, find a blank line after the import statements and type this line exactly:

sys.path.append('C:\\Users\\YourName\\MyPythonModules')

Replace C:\\Users\\YourName\\MyPythonModules with the actual path to your folder. On Windows, use backslashes and make sure to use double backslashes (\\) in the code, or use forward slashes (/) instead — Python accepts both. On macOS or Linux, use forward slashes only: /Users/YourName/MyPythonModules.

If your folder path has spaces in it, like C:\Program Files\My Modules, the quotes around the path will protect it. You can add as many sys.path.append() lines as you need, one per directory.

After you type each line, press Enter to move to the next line. Do not add extra spaces or change the punctuation — Python is strict about syntax.

Saving the file and restarting PyScripter

Once you have added your path lines, save the file. In most text editors, press Ctrl+S on Windows or Command+S on macOS. Close the text editor completely.

Now close PyScripter entirely — do not just close the script window, close the whole process. On Windows, click the X button in the top right corner of the PyScripter window. On macOS, press Command+Q or click PyScripter in the menu bar and select Quit.

Wait a few seconds, then open PyScripter again. If the IDE starts normally, your changes worked. If PyScripter fails to start or shows an error, you likely made a syntax error in __init__.py. Restore your backup file, and try again more carefully.

Testing that your new path works

To confirm that PyScripter can now find your modules, write a short test script. Open a new file in PyScripter and type:

import sys print(sys.path)

Run this script by pressing F5 or clicking the Run button. The output will show every directory in your Python path. Look for the directory you added — if it appears in the list, your change worked.

Next, try importing one of your modules. If you added a folder containing a file called mymodule.py, type import mymodule in a test script and run it. If there is no error, PyScripter found your module.

What to do if your changes do not work

If PyScripter still cannot find your module after you have added the path, check these things: First, make sure the path you typed is exactly correct — copy and paste the full path from File Explorer or Finder to avoid typos. Second, confirm that your module file actually lives in that folder. Third, restart PyScripter again — sometimes the change does not take effect until you close and reopen the process a second time.

If you see an error message when PyScripter starts, you made a syntax error in __init__.py. Restore your backup file and try again. Common mistakes are forgetting the quotes around the path, using single backslashes instead of double backslashes on Windows, or leaving out the parentheses after sys.path.append.

If you are still stuck, check whether your module is in a subfolder. Python does not automatically search subfolders — you have to point to the exact folder where the .py file lives.

Frequently Asked Questions

Can I use relative paths instead of full paths in __init__.py?

Relative paths (like ./mymodules) can work, but they are unreliable in __init__.py because PyScripter may not be running from the folder you expect. Use full paths (like C:\Users\YourName\mymodules) to avoid confusion.

What is the difference between sys.path.append() and sys.path.insert()?

sys.path.append() adds your folder to the end of the search list, so Python checks built-in modules first. sys.path.insert(0, 'path') adds it to the beginning, so Python checks your folder first. Use append() unless you have a reason to override built-in modules.

Do I need to restart my computer after changing __init__.py?

No. Closing and reopening PyScripter is enough. You do not need to restart your computer or log out.

Will changing __init__.py affect Python outside of PyScripter?

No. Changes to PyScripter's __init__.py only affect scripts run inside PyScripter. Your system Python path and other IDEs remain unchanged.

What if I accidentally delete __init__.py?

Reinstall PyScripter to restore the original file. If you kept a backup, you can also copy your backup back into the PyScripter folder and rename it to __init__.py.