0

I am trying to import socket and I get the following error:

$ python
Python 2.7.16 |Anaconda, Inc.| (default, Mar 14 2019, 16:24:02)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "socket.py", line 68, in <module>
    from _ssl import \
ImportError: cannot import name RAND_egd

I thought that perhaps my Anaconda installation was corrupted so I uninstalled and reinstalled Anaconda but the error persists.
I had tried what the other posts suggested except for editing socket.py due to Macos System Integrity Protection. My guess is that the problem lies elsewhere as I doubt that everyone has had to edit the file.

How can I find the source of the problem?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
ihf
  • 51
  • 1
  • 9
  • Please show the actual import(s), a full stack trace if there is one, and maybe a list of the Anaconda packages in your environment. The error messages says `_ssl`, which seems like a package you shouldn't import directly. – Roland Weber Jun 22 '19 at 07:24
  • If you're switching between different Python versions, this might help: https://stackoverflow.com/a/32506523/11451509 – Roland Weber Jun 22 '19 at 07:25
  • Possible duplicate of [ImportError: cannot import name RAND\_egd](https://stackoverflow.com/questions/31762371/importerror-cannot-import-name-rand-egd) – Roland Weber Jun 22 '19 at 07:25
  • Please add additional information by editing your question, not by commenting on it. – Roland Weber Jun 23 '19 at 07:23

0 Answers0