I know that I can add an import path to Python like this:
import sys
sys.path.append("/path/to/directory/")
But, when I restart Python, this is gone. I'd find it quite annoying if I had to do this all the time, I'd like to do this once and for all and be done with it.
So, how? Where can I find that file? Or do I need to edit something else? I'm using the latest version of Ubuntu.
execute following from the shell:
and restart it
From man python
You can also use a path file.
If you want to add a module called mymodule to your import path, add the file mymodule.pth to the standard directory for 3rd party modules, usually called dist-packages, or site-packages. On Ubuntu you will probably find it somewhere like
The file mymodule.pth should contain a single line, the directory you want to add to the python import path
Any python modules or packages in the directory will now be importable from the interpreter.
You can set a environmental variable called
PYTHONPATH
to include you directory.Read more about it in the docs