Can't Find My Pythonpath
Solution 1:
At runtime, you can change it with:
import sys
sys.path.append('...')
In My Computer, right-click Properties (or press Win-Break), System tab, Environment Variables, System. You can add it if it's not already there.
Finally, in the CMD prompt:
set PYTHONPATH C:\Python25\Lib;C:\MyPythonLib
Or in bash:
PYTHONPATH=/usr/share/python/lib:/home/me/python
export PYTHONPATH
Or, more succinctly:
exportPYTHONPATH=/home/me/python
Solution 2:
Python does some stuff up front when it is started, probably also setting that path in windows. Just set it and see, if it is changed in sys.path.
Setting environment variables in the Python docs say:
My Computer ‣ Properties ‣ Advanced ‣ Environment Variables
Solution 3:
You can add it under "My Computer" if it doesn't exist. PYTHONPATH just adds to the default sys.path.
On unix/linux/osx you can:
$ exportPYTHONPATH=/to/my/python/libs
You can also use .pth files to point to libraries:
http://docs.python.org/library/site.html#module-site
And of course:
import sys
sys.path.append('/path/to/libs/')
Also, check out virtualenv for managing libraries for multiple projects.
Solution 4:
Here's how I solved it.
First, get the current path. There's a lot more there than I expected.
import sys
print';'.join(sys.path)
Copy that result to the clipboard. Go to My Computer and create the new environment variable PYTHONPATH, and for the value paste from the clipboard. Modify as necessary.
Solution 5:
MacOS 10.5.8, Python 2.6, Eclipse+Pydev 1.5.7
Python installation's site-package is, for example:
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packagescreate symlinks YOUR LIBRARY inside into site-package, for example:
Now You can use in commandline:cd /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages ln -s /path/to/YOUR/LIBRARY/ YOUR_LIBRARY_NAMEimport YOUR_LIBRARY_NAMErun Eclipse with Pydev, go to Preferences->Pydev->Interpreter Python
remove Your Python interpreter record, if exists;
click New and add Python 2.6 interpreter path, for example:
/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6notice, that Eclipse Pydev display Python System Library, accept that
in Library section click New Folder and write path to YOUR LIBRARY, for example:
/path/to/YOUR/LIBRARY/click Apply - it is essential, because Eclipse Pydev built now his own "library map", when this operation finish - click [OK]
close Eclipse
run Eclipse again - now You should use in Pydev:
import YOUR_LIBRARY_NAME
Post a Comment for "Can't Find My Pythonpath"