Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named _ssl

Ubuntu Maverick w/Python 2.7:

I can't figure out what to do to resolve the following import error:

>>> import ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/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

UPDATE: I recompiled the source. I was unable to figure out how to add the --with-ssl option the answers below mention, instead I got this to work by editing the lines regarding SSL in /Modules/Setup.dist.

like image 963
J Cooper Avatar asked Feb 26 '11 18:02

J Cooper


People also ask

How do I fix the ImportError No module named error in Python?

To get rid of this error “ImportError: No module named”, you just need to create __init__.py in the appropriate directory and everything will work fine.

How do you fix ModuleNotFoundError and ImportError?

Python's ImportError ( ModuleNotFoundError ) indicates that you tried to import a module that Python doesn't find. It can usually be eliminated by adding a file named __init__.py to the directory and then adding this directory to $PYTHONPATH .


2 Answers

Unrelated to the original question, but because this is the first Google result... I hit this on Google AppEngine and had to add:

libraries:
- name: ssl
  version: latest

to app.yaml per: https://cloud.google.com/appengine/docs/python/sockets/ssl_support

Please NOTE: This seems to work upto Python version 2.7.9 but not for 2.7.10 or 2.7.11.

like image 90
slumtrimpet Avatar answered Nov 16 '22 17:11

slumtrimpet


Did you build the Python from source? If so, you need the --with-ssl option while building.

like image 33
Utku Zihnioglu Avatar answered Nov 16 '22 15:11

Utku Zihnioglu