ubuntu 18.04 ImportError: No module named _backend_gdk - python

when I use superplot_gui it comes out the error:
Could not load matplotlib - GTK backend.
Your version of matplotlib may not be compiled with GTK support.
Reinstalling matplotlib may fix this problem - see README or user manual for instructions
>Traceback (most recent call last):
File "super_gui.py", line 32, in <module>
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas
File "/home/xxxxx/.local/lib/python2.7/site-packages/matplotlib/backends/backend_gtkagg.py", line 12, in <module>
from matplotlib.backends.backend_gtk import (
File "/home/xxxxx/.local/lib/python2.7/site-packages/matplotlib/backends/backend_gtk.py", line 38, in <module>
from matplotlib.backends.backend_gdk import RendererGDK, FigureCanvasGDK
File "/home/xxxxx/.local/lib/python2.7/sitepackages/matplotlib/backends/backend_gdk.py", line 29, in <module>
from matplotlib.backends._backend_gdk import pixbuf_get_pixels_array
ImportError: No module named _backend_gdk
I did not get this problem before I upgrade my ubuntu 16.04 to 18.04
I have tried the solution in other related question but they does not work.

Related

ModuleNotFoundError: No module named 'tensorflow.core'

My python version is python3.8.8.
I installed tensorflow2.7 on a linux server.
And when I import tensorflow.keras. It shows error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/research/dept8/msc/xcxia21/anaconda3/lib/python3.8/site-packages/tensorflow/__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "/research/dept8/msc/xcxia21/anaconda3/lib/python3.8/site-packages/tensorflow/python/__init__.py", line 41, in <module>
from tensorflow.python.eager import context
File "/research/dept8/msc/xcxia21/anaconda3/lib/python3.8/site-packages/tensorflow/python/eager/context.py", line 47, in <module>
from tensorflow.python.util.deprecation import deprecated
File "/research/dept8/msc/xcxia21/anaconda3/lib/python3.8/site-packages/tensorflow/python/util/deprecation.py", line 32, in <module>
from tensorflow.tools.docs import doc_controls
ModuleNotFoundError: No module named 'tensorflow.tools'
I tried to uninstall tensorflow2.7 and install older version tensorflow2.2
the error becomes:
Traceback (most recent call last):
File "cnn_mnist1.py", line 7, in <module>
import tensorflow.keras as keras
File "/research/dept8/msc/xcxia21/anaconda3/lib/python3.8/site-packages/tensorflow/__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "/research/dept8/msc/xcxia21/anaconda3/lib/python3.8/site-packages/tensorflow/python/__init__.py", line 53, in <module>
from tensorflow.core.framework.graph_pb2 import *
ModuleNotFoundError: No module named 'tensorflow.core'
I am confused about why I need to import tensorflow.tools or tensorflow.core when I only want to import tensorflow.keras?
Someone told me I should build a virtual environment to deal with it. But I would like to know why tensorflow.tools and tensorflow.core are missing?
Besides, when I install tensorflow using pip. The installation always stops(see below). Several minutes later I have to terminate it. Does it cause some packages missing?
Thank you!
Tensorflow 2.7 requires to install keras individually with pip install keras an then you can use keras like before the release: from tensorflow import keras.

AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'

Im new to programming, so I have met this trouble.
I ve upgraded my pip and then used pip list, ipython notebook, jupyter notebook to use anaconda, so after all this commands I got one answer :
Traceback (most recent call last):
File "/home/bakhytgul/anaconda3/bin/pip", line 7, in <module>
from pip._internal import main
File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_internal/__init__.py", line 40, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_internal/cli/main_parser.py", line 12, in <module>
from pip._internal.commands import (
File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_internal/commands/__init__.py", line 6, in <module>
from pip._internal.commands.completion import CompletionCommand
File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_internal/commands/completion.py", line 6, in <module>
from pip._internal.cli.base_command import Command
File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 19, in <module>
from pip._internal.download import PipSession
File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_internal/download.py", line 15, in <module>
from pip._vendor import requests, six, urllib3
File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_vendor/requests/__init__.py", line 97, in <module>
from pip._vendor.urllib3.contrib import pyopenssl
File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/OpenSSL/crypto.py", line 13, in <module>
from cryptography.hazmat.primitives.asymmetric import dsa, rsa
File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/cryptography/hazmat/primitives/asymmetric/rsa.py", line 14, in <module>
from cryptography.hazmat.backends.interfaces import RSABackend
File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/cryptography/hazmat/backends/__init__.py", line 7, in <module>
import pkg_resources
File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pkg_resources.py", line 1435, in <module>
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
Can u help me to solve this issue, please? Thank u very much.
Im using:
- Ubuntu 16.04. (64bit)
- Python 2.7.12
- Python 3.6.0 :: Anaconda 4.3.1 (64-bit)
P.S: Ive tried to fix with dotenv, ensurepip(this got me answer that I dont have this package).
Not a full answer because I cannot tell you why this is happening, but hopefully this will help you find a solution.
I had been running into this problem with an venv. When I started from scratch trying to build rjsmin, everything went all right, that is when I noticed that the reason was that the venv that was failing was using Python 3.6, whereas the new venv was using Python 3.7.
According to your console output the anaconda you have is using 3.6, I think you might have break your install by manually upgrading packages using pip. You could try getting the newer version of anaconda, or go with a new, fresh install.

Python embedding, ImportError: cannot import name _remove_dead_weakref

I am trying to run some C++ code with embedded Python. Code was working completely fine a couple of weeks ago. The code still compiles, but I am now getting the error
Traceback (most recent call last):
File "./main.py", line 1, in <module>
import numpy as np
File "/usr/local/lib/python2.7/site-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/usr/local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python2.7/site-packages/numpy/core/__init__.py", line 74, in <module>
from numpy.testing.nosetester import _numpy_tester
File "/usr/local/lib/python2.7/site-packages/numpy/testing/__init__.py", line 10, in <module>
from unittest import TestCase
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/__init__.py", line 64, in <module>
from .main import TestProgram, main
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 7, in <module>
from . import loader, runner
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/runner.py", line 7, in <module>
from .signals import registerResult
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/signals.py", line 2, in <module>
import weakref
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
Since then the only change I have made is to install the macOS Supplemental Update and to upgrade Python from 2.7.13_1 to 2.7.14_2 (using Homebrew). I have changed the relevant linker flags in the makefile, i.e. those that appear when I type python-config --ldflags. I have also made sure that the Python I am using is definitely the Homebrew one by inserting export PATH="/usr/local/opt/python/libexec/bin:$PATH" into my .bash_profile as directed by Homebrew.
I am not sure whether this error is because of the Python update, the recent macOS Supplemental Update, or something else. Any idea what the problem could be?
Thanks
I had the same problem;
In python 2.7 the NumPy 1.8.0 was available,
Then I installed NumPy (again) using brew, and it wasn't available in my python (2.7) anymore. (Got the same error you got here)
So I did "brew unlink python && brew link python" to use python 3 (instead of 2) which NumPy 1.14 is available in it.
I guess the python 2.7 was not compatible with this recent version of NumPy.

Importing matplotlib in Spyder (OSX 10.6)

When importing matplotlib in Spyder I get the following:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/matplotlib/pyplot.py", line 27, in <module>
import matplotlib.colorbar
File "/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/matplotlib/colorbar.py", line 34, in <module>
import matplotlib.collections as collections
File "/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/matplotlib/collections.py", line 27, in <module>
import matplotlib.backend_bases as backend_bases
File "/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/matplotlib/backend_bases.py", line 56, in <module>
import matplotlib.textpath as textpath
File "/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/matplotlib/textpath.py", line 19, in <module>
import matplotlib.font_manager as font_manager
File "/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/matplotlib/font_manager.py", line 57, in <module>
from matplotlib import ft2font
ImportError: dlopen(/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/matplotlib/ft2font.so, 2): Symbol not found: _inflateReset2
Referenced from: /Applications/Spyder-Py2.app/Contents/MacOS/../Frameworks/libpng16.16.dylib
Expected in: /usr/lib/libz.1.dylib
in /Applications/Spyder-Py2.app/Contents/MacOS/../Frameworks/libpng16.16.dylib
What can I do? I really don't get it. I run under mac OSX 10.6
(Spyder dev here) The problem lies in some changes done by the Matplotlib team some time ago that made for us harder to support Mac OSX 10.6.
To do it, we would need to include our own version of zlib in our Mac app, and compile every package against it, something I considered too much work and a potential cause of bugs.
That's why I changed the minimal required version of our app to be 10.7, as can be seen in our documentation site.

ImportError: Module use of python26.dll conflicts with this version of Python

I use Python 3.2.3
Tonight I tried to install requests from http://docs.python-requests.org/en/latest/ by pip and easy_install, but it doesn't work. I have error when trying to import it. So I decided to use standard library urllib.request and see this error again
That is the traceback:
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "E:\Python32\lib\site-packages\requests-1.2.0-py3.2.egg\requests\__init__.py", line 52, in <module>
from . import utils
File "E:\Python32\lib\site-packages\requests-1.2.0-py3.2.egg\requests\utils.py", line 12, in <module>
import cgi
File "E:\Python32\lib\cgi.py", line 38, in <module>
from email.parser import FeedParser
File "E:\Python32\lib\email\parser.py", line 12, in <module>
from email.feedparser import FeedParser
File "E:\Python32\lib\email\feedparser.py", line 27, in <module>
from email import message
File "E:\Python32\lib\email\message.py", line 17, in <module>
from email import utils
File "E:\Python32\lib\email\utils.py", line 28, in <module>
import socket
File "E:\Python32\lib\socket.py", line 46, in <module>
import _socket
ImportError: Module use of python26.dll conflicts with this version of Python.
So how can I fix this?
UPD: Solved. It was bug in SublimeREPL, reinstalled that package.
I had a similar problem when I was using PythonXY. The Spyder was not loading and it turns out another software OpenCAD had installed Python2.6 version and that was not letting my Python27.dll to not work. After uninstalling OpenCAD, I was able to run the software.
I was able to troubleshoot by first searching for python26.dll and found that this file was located in the OpenCAD folder location and that made me realize that this software was causing the issue.

Categories

Resources