I would like to use a package in /usr/local/lib/python2.6/dist-packages/<this package>. But from what I checked from sys.path, this package is not in the path, so Python uses the package in /usr/lib/python2.6/dist-packages instead. How can I fix it?
1 Answer
If this is for one script/program only I would just add to the top of the script:
import sys
sys.path.insert(0, '/usr/local/lib/python2.6/dist-packages')
If this happens more often then either remove the package from /usr/lib/python2.6/dist-packages if you can, or set the PYTHONPATH environment variable during login.
sys.path.append("/usr/local/lib/python2.6/dist-packages/")? (Or perhaps, since it looks like it's defaulting to another folder,sys.path = ["/usr/local/lib/python2.6/dist-packages/"] + sys.path?)