I'm novice in this, and I have started learning Python, but I have some questions that I'm not be able to understand,
python_)?Type open . bash_profile. In the text file that pops up, add this line at the end: export PYTHONPATH=$PYTHONPATH:foo/bar. Save the file, restart the Terminal, and you're done.
Setting Path at Unix/LinuxIn the csh shell − type setenv PATH "$PATH:/usr/local/bin/python3" and press Enter. In the bash shell (Linux) − type export PYTHONPATH=/usr/local/bin/python3. 4 and press Enter. In the sh or ksh shell − type PATH = "$PATH:/usr/local/bin/python3" and press Enter.
One of the most important things to note when you are adding Path to Python in Unix or Linux is that, /usr/local/bin/python is the default path of the Python directory.
1) PYTHONPATH is 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}/foo Here I use the sh syntax. 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).
2) 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.
3) The folder where your modules live is dependent on PYTHONPATH and 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 command ls -- where does ls live? /usr/bin? /bin? 99% of the time, you don't need to care -- Just use ls and be happy that it lives somewhere on your PATH so the shell can find it.
4) 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.
5) Configure PYTHONPATH to include the directory where your module resides and python will be able to find your module.
PYTHONPATH is an environment variable /usr/lib/python2.7 on UbuntuPYTHONPATH explicitlyIf you look at the instructions for pyopengl, you'll see that they are consistent with points 4 and 5.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With