- Add the path to the directory you want to add to the Python path:
PYTHONPATH=”$PYTHONPATH:/path/to/directory”
- Save the changes and exit nano by pressing Control + X, then Y, then Enter
- Restart your terminal or computer for the changes to take effect
Checking the Python Path
You can check the current Python path by running the following code in a Python shell:
import sys print(sys.path)
This code will print a list of directories that Python is searching for modules and packages. If you’ve added directories to the PYTHONPATH variable, they should appear in this list.