python 2.7 - import httplib2 works in mac terminal but not IDLE shell -
i'm having great problems getting python site package httplib2 work in idle. i'm using mac osx 10.8.3 , python 2.7. used following installation steps install httplib2 macports:
1. $sudo port install py27-httplib2
i checked installed using:
2. $port contents py27-httplib2
which returned whole pile of files in following directory (i'm showing first three):
/opt/local/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/httplib2-0.8-py2.7.egg-info /opt/local/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/httplib2/__init__.py /opt/local/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/httplib2/__init__.pyc
then added following lines .bash_profile file thus:
$echo "export pythonpath=\"/opt/local/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/httplib2:$pythonpath\"">>.bash_profile $source .bash_profile
i checked paths had indeed been incorporated environment (but noticed path messy):
$env path=/sw/bin:/sw/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin: /opt/local/sbin:/opt/local/bin:/opt/local/sbin: /library/frameworks/python.framework/versions/2.7/bin:/usr/bin:/bin: /usr/sbin:/sbin:/usr/local/bin:/opt/x11/bin:/usr/local/mysql/bin: /users/lydia/programs/pagan/bin pwd=/users/lydia lang=en_au.utf-8 shlvl=1 home=/users/lydia pythonpath=/opt/local/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/httplib2: /opt/local/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages:
i invoked python , ran 2 lines of code in terminal window shown below:
$python >>> import sys >>> import httplib2
if run same 2 lines of code in idle following error:
>>> import httplib2 traceback (most recent call last): file "<pyshell#0>", line 1, in <module> import httplib2 importerror: no module named httplib2
my question is: must idle recognise httplib2 installed , has valid path? need code work on various machines can't hard-code path httplib2 in code.
thanks in advance!
1) should never care python interpreter does. not same running python program, , in opinion useless. instead, type code file named my_prog.py, , run it:
$ python my_prog.py
2) should never care idle because worst text editor imaginable. mac comes vim, can learn how use doing:
$ vimtutor
once you've learned basics, can upgrade , install macvim, , vivid chalk color scheme, real sharp looking editor. there thousands of useful plugins can employ macvim. can search google "best of macvim plugins" , see ones might want.
3) why use macports install modules? can download module, untar it:
.../downloads$ tar xfvz some-name.tar.gz
then cd newly created directory:
.../downloads$ cd some-name
then read readme or install file directions on how install module, typically is:
.../downloads/some-name$ sudo python setup.py install
that install python module in default location, not /opt/local on mac; it's:
/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages
you shouldn't need macports trivial.
4) looks other people have had problems idle when installing modules in non-standard locations, might want search google , see if can find solution there: e.g. http://ubuntuforums.org/showthread.php?t=253555
Comments
Post a Comment