-
PYTHONPATHis an environment variable which you can set to add additional directories where python will look for modules and packages. e.g.:# make python look in the foo subdirectory of your home directory for # modules and packages export PYTHONPATH=${PYTHONPATH}:${HOME}/fooHere I use the
shsyntax. For other shells (e.g.csh,tcsh), the syntax would be slightly different. To make it permanent, set the variable in your shell’s init file (usually ~/.bashrc). -
Ubuntu comes with python already installed. There may be reasons for installing other (independent) python versions, but I’ve found that to be rarely necessary.
-
The folder where your modules live is dependent on
PYTHONPATHand where the directories were set up when python was installed. For the most part, the installed stuff you shouldn’t care about where it lives — Python knows where it is and it can find the modules. Sort of like issuing the commandls— where doeslslive?/usr/bin?/bin? 99% of the time, you don’t need to care — Just uselsand be happy that it lives somewhere on yourPATHso the shell can find it. -
I’m not sure I understand the question. 3rd party modules usually come with install instructions. If you follow the instructions, python should be able to find the module and you shouldn’t have to care about where it got installed.
-
Configure
PYTHONPATHto include the directory where your module resides and python will be able to find your module.