Appending paths to Python's sys.path is pretty important if you are learning Python or testing some application in your local machine. If you append paths to sys.path by import sys and sys.path.append("/path/") it will only be temporary: once you restart the interpreter it won't work anymore. A permanent solution is editing the site.py file.
Just open your favourite text-editor with admin privileges (I did gksu gedit), and open /etc/python2.x/site.pysite.py is the file that python interpreter looks up when it is invoked file. (2.x is the Python version) Now, add these two lines to site.py:
import sys
sys.path.append("/path/you/want/to/append/")

Done! Source: TheScripts To check if everything's done, restart the interpreter and run these commands:
import sys
sys.path[-1]

And we will be greeted with the path you just added. ;)

Labels: ,

blog comments powered by Disqus