Example Code
Here’s an example of how you can modify the default Python path in your code:
import sys sys.path.append('/path/to/directory')
This code adds the directory /path/to/directory to the Python path, allowing you to import modules and packages from that directory.
Adding Directories to PYTHONPATH Permanently
Adding directories to the PYTHONPATH variable using the export command is only temporary. If you close the terminal or restart your computer, the changes will be lost. To add directories to PYTHONPATH permanently, you need to modify the environment variables on your operating system.