matplotlib GTK ImportError - python

I installed matplotlib with brew install matplotlib --with-cairo --with-pygtk --with-python3. Running import matplotlib.pyplot causes a GTK ImportError. The ImportError is slightly different for Python 2 and 3.
Python 2:
$ python
Python 2.7.8 (default, Oct 16 2014, 05:18:45)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.51)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/matplotlib-override/matplotlib/pyplot.py", line 98, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/Library/Python/2.7/site-packages/matplotlib-override/matplotlib/backends/__init__.py", line 28, in pylab_setup
globals(),locals(),[backend_name],0)
File "/Library/Python/2.7/site-packages/matplotlib-override/matplotlib/backends/backend_gtkcairo.py", line 12, in <module>
from matplotlib.backends.backend_gtk import *
File "/Library/Python/2.7/site-packages/matplotlib-override/matplotlib/backends/backend_gtk.py", line 33, in <module>
from matplotlib.backends.backend_gdk import RendererGDK, FigureCanvasGDK
File "/Library/Python/2.7/site-packages/matplotlib-override/matplotlib/backends/backend_gdk.py", line 30, in <module>
from matplotlib.backends._backend_gdk import pixbuf_get_pixels_array
ImportError: No module named _backend_gdk
Python 3:
$ python3
Python 3.4.2 (default, Oct 16 2014, 05:21:12)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.51)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/site-packages/matplotlib/pyplot.py", line 109, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/local/lib/python3.4/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/usr/local/lib/python3.4/site-packages/matplotlib/backends/backend_gtkcairo.py", line 10, in <module>
import gtk
ImportError: No module named 'gtk'

Related

ImportError: cannot import name '_has_torch_function' from 'torch._C'

When I import torch, I get the following error:
I dont know if it has something to do with the fact i just install cuda11.6.
I tried to unintalled and install pytorch , it didn't work.
Python 3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 06:08:21)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/zengyunzi1/.conda/envs/yz/lib/python3.7/site-packages/torch/__init__.py", line 603, in <module>
from ._tensor import Tensor
File "/home/zengyunzi1/.conda/envs/yz/lib/python3.7/site-packages/torch/_tensor.py", line 15, in <module>
from torch.overrides import (
File "/home/zengyunzi1/.conda/envs/yz/lib/python3.7/site-packages/torch/overrides.py", line 33, in <module>
from torch._C import (
ImportError: cannot import name '_has_torch_function' from 'torch._C' (/home/zengyunzi1/.conda/envs/yz/lib/python3.7/site-packages/torch/_C.cpython-37m-x86_64-linux-gnu.so)
>>>

Ubuntu + new user + ImportError: No module named 'google'

I create a new user in Ubuntu16.04. But I can't import tensorflow in the new user. It hint me that, ImportError: No module named 'google'
I use the tensorflow-gpu==1.7.0 + cuda-9.0 + cudnn-7.0 and python 3.5
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
`>>>`import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import * # pylint: disable=redefined-builtin
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/core/framework/graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
ImportError: No module named 'google'
You tried the command:
pip3 install google --user
?

python seaborn lib throwing error on import

I am loading missingno lib on python as provided below.
while loading , it throws error at seaborn/rcmod.py.
following are the versions,-
missingno-0.3.8
numpy-1.9.0
matplotlib-1.5.0
seaborn==0.8.1
Python 2.6.6 (r266:84292, Jul 23 2015, 05:13:40)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import missingno as mn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/missingno/__init__.py", line 1, in
<module>
from .missingno import matrix
File "/usr/lib/python2.6/site-packages/missingno/missingno.py", line 6, in
<module>
import seaborn as sns
File "/usr/lib/python2.6/site-packages/seaborn/__init__.py", line 6, in
<module>
from .rcmod import *
File "/usr/lib/python2.6/site-packages/seaborn/rcmod.py", line 161
style_dict = {k: mpl.rcParams[k] for k in _style_keys}
^
SyntaxError: invalid syntax
seaborn doesn't support Python 2.6: https://github.com/mwaskom/seaborn/blob/88c49ef6c14ca69def8195f03d467915b3b0597c/setup.py#L82
You need to update your Python to at least Python 2.7 to use seaborn.

Macports Installed Python 2.7 Inccorectly Imports Python 3.5 Numpy

I have a macports installed python however, whenever I try to import numpy after launching python I get the following error message:
Python 2.7.11 (default, Mar 1 2016, 18:40:10)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
import numpy
Traceback (most recent call last):
File "", line 1, in
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/init.py", line 180, in
from . import add_newdocs
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/add_newdocs.py", line 13, in
from numpy.lib import add_newdoc
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/lib/init.py", line 8, in
from .type_check import *
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/lib/type_check.py", line 11, in
import numpy.core.numeric as _nx
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/core/init.py", line 14, in
from . import multiarray
ImportError: cannot import name multiarray
I should also add that I have py27-numpy installed.. however python27 always seems to look for py35-numpy.

Error in Import psutill - Python ver-2.7.7 psutil ver-2.1.3

I am trying to import psutil on python and this is what i get:
Python 2.7.7 (v2.7.7:f89216059edf, May 31 2014, 12:53:48)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psutil/__init__.py", line 148, in <module>
import psutil._psosx as _psplatform
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psutil/_psosx.py", line 29, in <module>
cext.TCPS_ESTABLISHED: _common.CONN_ESTABLISHED,
AttributeError: 'module' object has no attribute 'TCPS_ESTABLISHED'

Categories