How to set python environment variable PYTHONPATH on Linux?

PythonServer Side ProgrammingProgramming

To set the PYTHONPATH on linux to point Python to look in other directories for module and package imports, export the PYTHONPATH variable as follows:


In this case we are adding the foo directory to the PYTHONPATH. Note that we are appending it and not replacing the PYTHONPATH's original value. In most cases, you shouldn't mess with PYTHONPATH. More often than not, you are doing it wrong and it will only bring you trouble.

Updated on 11-Dec-2019 06:07:11