matplotlib: no module named compat - python

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

Related

ImportError: libc10.so: cannot open shared object file: No such file or directory

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.

Cannot use socket

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?

Why do I get a ModuleNotFoundError for winreg on a Linux system?

'winreg' module is not found python 3.6.7. I am not facing this problem in Python 3.4.
Is any third-party app in 'winreg' that I can use same code or how can I solve this.
jaki#jaki-notebook:~$ python3 -V
Python 3.6.7
jaki#jaki-notebook:~$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from winreg import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'winreg'
>>>
ModuleNotFoundError: No module named 'winreg'
It is not work on linux because this package expose functions of the Windows registry API to Python
Read this documentation on python offical website

ciscoconfparse unable to import python3.7 win10

Any new solution for this. I am unable to from ciscoconfparse import CiscoConfParse
I tried several versions of ciscoconfparse in python3 usin gpowershell in windows10.
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ciscoconfparse import CiscoConfParse
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python3\lib\site-packages\ciscoconfparse\__init__.py", line 1, in <module>
from .ciscoconfparse import *
File "C:\Python3\lib\site-packages\ciscoconfparse\ciscoconfparse.py", line 4018
^
SyntaxError: invalid syntax
I still have not found a version that will let me import the module.
I browsed through several links here..but did not find an answer. The closest issue to mine is:
ciscoconfparse in Python 3.4 module doesn't import correctly
but not answer.
Any new info?
Thanks
I have reproduced the bug where Win10 and Python 3.7.0 cause problems.
FWIW, if you completely uninstall Python 3.7.0 (including manually deleting your Windows installation directory tree), then install Python 3.7.1, you should not have this problem with Windows 10.

How to solve AttributeError when importing igraph?

When I import the igraph package in my project, I get an AttributeError. This only happens in the project directory:
[12:34][~]$ python2
Python 2.7.1 (r271:86832, Apr 15 2011, 12:09:10)
[GCC 4.5.2 20110127 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import igraph
>>>
[12:34][~]$ cd projectdir/
[12:34][projectdir]$ python2
Python 2.7.1 (r271:86832, Apr 15 2011, 12:09:10)
[GCC 4.5.2 20110127 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import igraph
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/igraph/__init__.py", line 42, in <module>
import gzip
File "/usr/lib/python2.7/gzip.py", line 36, in <module>
class GzipFile(io.BufferedIOBase):
AttributeError: 'module' object has no attribute 'BufferedIOBase'
>>>
There is no file igraph.py in the project directory:
[12:34][projectdir]$ ls -alR | grep igraph | wc -l
0
And there are no circular imports.
How can I solve this error?
Most likely, there is a module io in ~/projectdir or one of the paths the project configures. The gzip module imported by igraph starts with
import io
and expect the built-in io module, not your project's one. Look for an io directory, or io.py or io.pyc. It can also help to scrutinize sys.path for any other directories (maybe outside of ~/projectdir) that might contain modules named io.

Categories

Resources