I've written as minimal a python program using argparse as I can. Just three lines.
import argparse
if __name__ == "__main__":
print "Hello World"
It gets the following error:
File "/Users/pfarrell/sandbox/dbms/extractor/src/extractor.py", line 2, in import argparse ImportError: No module named argparse
This is the first python program I've ever written, so I can easily believe that I've not properly setup some python library path, etc.
This is running on OS-X
python --version
Python 2.7.1
pfarrell@way:~/sandbox/dbms/extractor/src$ python -c "import argparse; print argparse"
<module 'argparse' from '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/argparse.pyc'>
More testing (thanks to the comments)
running it explicitly in the shell works, but running it inside netbeans fails:
shell only
python extractor.py -h
Hello World
usage: extractor.py [-h]
optional arguments:
-h, --help show this help message and exit
Running it as a script shows a completely different path. Looks like the netbeans setup needs a tweak or two
./extractor.py -h
/Users/pfarrell/sandbox/dbms/extractor/src
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib- scriptpackages
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC
/Library/Python/2.7/site-packages
Hello World
executing inside netbeans
/Users/pfarrell/sandbox/dbms/extractor/src
/Users/pfarrell/Library/Application Support/NetBeans/7.2.1/jython-2.5.1/Lib
/Users/pfarrell/Library/Application Support/NetBeans/7.2.1/jython-2.5.1/Lib/site-packages
/Users/pfarrell/sandbox/dbms/extractor/src
__classpath__
__pyclasspath__/
Hello World