Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am running a self-compiled version on python2.7, --prefix=$HOME, so as not to interfere with the standard installation of python2.6 (on Ubuntu 10.04). Had some problem importing the ssl modules, tracked down the problem, re-compiled my python2.7 and came to test it:

$ ~/bin/python2.7 -c "import ssl"

Looking good, double check

$ python2.7 -c "import ssl"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/jab/lib/python2.7/ssl.py", line 60, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: No module named _ssl

Eh? There's no other installation of python2.7 on this machine

$ which python2.7
~/bin/python2.7
$ echo $PATH
/home/jab/bin:/usr/local/bin:/usr/bin:/bin:...
$ for dir in $(echo $PATH | tr ':' ' '); do ls $dir/python2.7 2>/dev/null; done
/home/jab/bin/python2.7

Just to be extra sure:

$ python2.7 -c "import sys; print sys.executable"
/home/jab/bin/python2.7

$ $(which python2.7) -c "import sys; print sys.executable"
/home/jab/bin/python2.7

Enough with the context already. The question is: why does this work?

$(which python2.7) -c "import ssl"

when this does not?

$ python2.7 -c "import ssl"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/jab/lib/python2.7/ssl.py", line 60, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: No module named _ssl
share|improve this question
    
To see where the imports are coming from, add -v. Is there a difference between python2.7 -c 'import sys; print "\n".join(sys.path)' and $(which python2.7) -c 'import sys; print "\n".join(sys.path)'? What if you add -s? What if you add -S? –  Gabe Apr 26 '13 at 12:35
    
$ python2.7 -v gives the same error, $ ~/bin/python2.7 -v shows that ssl is a builtin module. -s and -S make no difference to the outputs –  jalanb Apr 26 '13 at 12:45
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.