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?
Related
While running smdataparallel, I see following error
# python
Python 3.6.10 |Anaconda, Inc.| (default, May 8 2020, 02:54:21)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import smdistributed.dataparallel.torch.distributed as dist
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/conda/lib/python3.6/site-packages/smdistributed/dataparallel/__init__.py", line 16, in <module>
import smddpcommon as hc
ImportError: libc10.so: cannot open shared object file: No such file or directory
libc10.so is made available by pytorch. Hence first
import torch
and then import packages that depend on pytorch.
You can use find to locate this file. For example, find YOUR_HOME_PATH -name "*libc10.so*". For example, I found /MY_HOME_PATH/anaconda3/envs/xrnerf/lib/python3.7/site-packages/torch/lib/libc10.so in mine.
When I try to import PYMC installed with pip, enpgk or the canopy GUI package manager, I tried all of them and without success.
Enthought Canopy Python 2.7.9 | 64-bit | (default, Jun 30 2015, 22:40:22)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-55)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/renanpc/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pymc/__init__.py", line 30, in <module>
from .CommonDeterministics import *
File "/home/renanpc/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pymc/CommonDeterministics.py", line 21, in <module>
from .utils import safe_len, stukel_logit, stukel_invlogit, logit, invlogit, value, find_element
File "/home/renanpc/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pymc/utils.py", line 14, in <module>
from . import flib
ImportError: libgfortran.so.1: cannot open shared object file: No such file or directory
I tried to install GFORTRAN with :
~$ sudo apt-get install gfortran-4.6
but I still get the same error.
(there are other questions very similar indeed, but usually the answer has to do with Anaconda and I'm using Canopy)
Any idea of what is going on ? I can import other packages.
I developed a Python package using Python 2.7 and 3.4, and now I'm trying to test it for 2.6 compatibility. So in Anaconda, I made a new conda environment for Python 2.6:
conda create -n python2.6 python=2.6.9 numpy scipy
But now, when I try to import some stuff from scipy:
$ python
Python 2.6.9 |Continuum Analytics, Inc.| (unknown, Jan 10 2014, 13:33:57)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy.sparse
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/jsleinon/anaconda/envs/python2.6/lib/python2.6/site-packages/scipy/sparse/__init__.py", line 212, in <module>
from .csr import *
File "/Users/jsleinon/anaconda/envs/python2.6/lib/python2.6/site-packages/scipy/sparse/csr.py", line 13, in <module>
from ._sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
ImportError: dlopen(/Users/jsleinon/anaconda/envs/python2.6/lib/python2.6/site-packages/scipy/sparse/_sparsetools.so, 2): Symbol not found: __ZNSaIcEC1Ev
Referenced from: /Users/jsleinon/anaconda/envs/python2.6/lib/python2.6/site-packages/scipy/sparse/_sparsetools.so
Expected in: dynamic lookup
Does anybody know a fix or a workaround? I'm using Mac OS X 10.9. The import works fine on 2.7 and 3.4.
I have installed python-2.7.5-5ubuntu3 and matplotlib-1.3.1-1ubuntu5 from the ubuntu 14.04 repository via apt-get. Trying to import the library in python 2.7 raises the following import error:
harold#ubuntu:~$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/share/pyshared/matplotlib/__init__.py", line 157, in <module>
from matplotlib.compat import subprocess
ImportError: No module named compat
>>>
I checked the directory /usr/share/pyshared/matplotlib and, indeed, cannot find any package called compat.
Any idea what is broken on my system?
Thanks!
I have found same problem on Ubuntu 16 & 14.
Possible source of the problem is damaged instance of matplotlib. Damaged instance overlaps working instance of matplotlib.
Please try to remove broken instance of matplotlib to solve the issue.
Firstly I have looked matplotlib instances:
find / |grep matplotlib | grep __init__\.py$ |more
Secondly I have deleted this folder:
find /usr/share/pyshared/matplotlib -delete
When I try to import pylons in the virtual python environment I get the error
C:\env\Scripts>python
Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (A
MD64)] on win32
Type "help", "copyright", "credits" or "license" for more informati
on.
>>> import pylons
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\env\lib\site-packages\pylons-1.0-py2.7.egg\pylons\__init
__.py", line 6, in <module>
from paste.registry import StackedObjectProxy
ImportError: No module named registry
As I understand this error, Python is telling me that it can not find the module named registry. Perhaps this is a result of the error I got while installing Pylons which is explained over here Why do I get an error on the last line of installing Pylons 1.0 with easy_install and Python 2.7 in Windows Vista 64?
It seems that many of the Pylon components were installed but I guess registry was not or maybe Pylons just can not see it.
Any ideas on how to solve this?
You have to activate the virtual environment before you can import pylons.
C:\Users\Josh>env\scripts\activate
(env) C:\Users\Josh>python
ActivePython 2.6.2.2 (ActiveState Software Inc.) based on
Python 2.6.2 (r262:71600, Apr 21 2009, 15:05:37) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pylons
>>>
vs. this
C:\Users\Josh\env\Scripts>python
ActivePython 2.6.2.2 (ActiveState Software Inc.) based on
Python 2.6.2 (r262:71600, Apr 21 2009, 15:05:37) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> pylons
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'pylons' is not defined
>>>
I guessing that you have the pylons package installed outside and inside your virtual environment. So python is letting you import pylons but the paste package is not installed outside of your virtual environment so you are getting an error.
Running the activate batch script (should be inside your env\Scripts folder) should solve the problem.