Error using tkagg backend - python-3.x

I am using the following setup:
Python 3.5.2 + Matplotlib 1.5.x (Raspberry Pi)
I have added backend :tkagg to my rc file.
If I run get_backend() it returns "tkagg"
However, when I try to import matplotlib as follows:
Python 3.4.2 (default, Oct 19 2014, 13:31:11)
[GCC 4.9.1] on linux
Type "copyright", "credits" or "license()" for more information.
>>> import matplotlib as mpl
>>> mpl.use('tkagg')
>>> import matplotlib.pyplot as plt
I receive the following traceback:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import matplotlib.pyplot as plt
File "/usr/local/lib/python3.4/dist-packages/matplotlib-1.5.0-py3.4-linux-armv7l.egg/matplotlib/pyplot.py", line 114, in <module>
backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/local/lib/python3.4/dist-packages/matplotlib-1.5.0-py3.4-linux-armv7l.egg/matplotlib/backends/__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/usr/local/lib/python3.4/dist-packages/matplotlib-1.5.0-py3.4-linux-armv7l.egg/matplotlib/backends/backend_tkagg.py", line 13, in <module>
import matplotlib.backends.tkagg as tkagg
File "/usr/local/lib/python3.4/dist-packages/matplotlib-1.5.0-py3.4-linux-armv7l.egg/matplotlib/backends/tkagg.py", line 9, in <module>
from matplotlib.backends import _tkagg
ImportError: cannot import name '_tkagg'
Why isn't matplotlib being imported correctly?

I basicly follow the instruction in this post:
tkagg backend problems
Then used git to get the source:
sudo git clone git://github.com/matplotlib/matplotlib.git
Then did build/install using Python3.4:
sudo python3.4 setup.py install

Related

ImportError: cannot import name parse_date while importing Pandas

Python 3.6.9 (default, Apr 18 2020, 01:56:04)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/suman/.local/lib/python3.6/site-packages/pandas/__init__.py", line 180, in <module>
import pandas.testing
File "/home/suman/.local/lib/python3.6/site-packages/pandas/testing.py", line 5, in <module>
from pandas._testing import (
File "pandas/src/testing.pyx", line 4, in init pandas._testing (pandas/src/testing.c:4068)
File "/home/suman/.local/lib/python3.6/site-packages/pandas/types/missing.py", line 5, in <module>
from pandas import lib
File "pandas/lib.pyx", line 1, in init pandas.lib (pandas/lib.c:87552)
File "pandas/tslib.pyx", line 67, in init pandas.tslib (pandas/tslib.c:109851)
ImportError: cannot import name parse_date
Make sure that you have installed pandas in the proper directiry:
pip install pandas
If you have already done so, it would be worth upgrading pandas:
pip install pandas --upgrade
Hi I got the same error today when I developed a pyqt project. I found there are two "pandas" when I uninstalled one then tried to install again. What I have done was uninstalling both two "pandas", then install the latest version, then it works. Although I solved this on Windows, but hope it is helpful to you.

ImportError: Incompatible library version for PIL/pillow

I recently installed shap, which requires pillow>=4.3.0 as:
$ pip3 install shap
Installing collected packages: shap, pillow
Successfully installed pillow-6.0.0 shap-0.29.2
Running my script that uses shap, I got:
Traceback (most recent call last):
File "Runner.py", line 132, in <module>
import shap
File "/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/shap/__init__.py", line 11, in <module>
from .plots.summary import summary_plot
File "/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/shap/plots/summary.py", line 15, in <module>
from . import colors
File "/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/shap/plots/colors.py", line 7, in <module>
import skimage.color
File "/Users/bravina/Library/Python/3.6/lib/python/site-packages/skimage/__init__.py", line 135, in <module>
from .data import data_dir
File "/Users/bravina/Library/Python/3.6/lib/python/site-packages/skimage/data/__init__.py", line 13, in <module>
from ..io import imread, use_plugin
File "/Users/bravina/Library/Python/3.6/lib/python/site-packages/skimage/io/__init__.py", line 7, in <module>
from .manage_plugins import *
File "/Users/bravina/Library/Python/3.6/lib/python/site-packages/skimage/io/manage_plugins.py", line 24, in <module>
from .collection import imread_collection_wrapper
File "/Users/bravina/Library/Python/3.6/lib/python/site-packages/skimage/io/collection.py", line 10, in <module>
from PIL import Image
File "/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/Image.py", line 93, in <module>
from . import _imaging as core
ImportError: dlopen(/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/_imaging.cpython-36m-darwin.so, 2): Library not loaded: #loader_path/.dylibs/libtiff.5.dylib
Referenced from: /usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/_imaging.cpython-36m-darwin.so
Reason: Incompatible library version: _imaging.cpython-36m-darwin.so requires version 10.0.0 or later, but libtiff.5.dylib provides version 8.0.0
Same thing if I try it directly in python3:
Python 3.6.4 (default, Jan 4 2018, 14:56:03)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/Image.py", line 93, in <module>
from . import _imaging as core
ImportError: dlopen(/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/_imaging.cpython-36m-darwin.so, 2): Library not loaded: #loader_path/.dylibs/libtiff.5.dylib
Referenced from: /usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/_imaging.cpython-36m-darwin.so
Reason: Incompatible library version: _imaging.cpython-36m-darwin.so requires version 10.0.0 or later, but libtiff.5.dylib provides version 8.0.0
Any tips as how to fix this?
Well, none of the answers suggested in this related post worked for me, so I ended up completely cleaning and reinstalling python3. From there, installing the necessary packages in a virtualenv as cleanly as possible seemed to resolve the issue...

Why aiohttp import shows below error?

The aiohttp module was installed successfully
But can not be imported as below info
[root#ceph_admin ~]# python3
Python 3.6.5 (default, Jul 1 2018, 23:52:30)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import aiohttp
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/aiohttp/__init__.py", line 6, in <module>
from .client import * # noqa
File "/usr/local/lib/python3.6/site-packages/aiohttp/client.py", line 17, in <module>
from . import client_exceptions, client_reqrep
File "/usr/local/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 17, in <module>
from . import hdrs, helpers, http, multipart, payload
File "/usr/local/lib/python3.6/site-packages/aiohttp/helpers.py", line 40, in <module>
import idna_ssl
File "/usr/local/lib/python3.6/site-packages/idna_ssl.py", line 1, in <module>
import ssl
File "/usr/local/lib/python3.6/ssl.py", line 101, in <module>
import _ssl # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'
The error above is
ModuleNotFoundError: No module named '_ssl'
So the real problem is my python3 can not import the module _ssl
My python 3.5 was installed from source code. Below are the correct ways to make python 3.5 have _ssl.
1. install openssl-devel by yum(My OS is CentOS)
2. compile your python source code with command (./configure && make && make install)

Can't import praw in Python3

I've been writing a reddit bot for a while now and recently moved it to a different system. There I've installed the same packages as on the previous system.
The bot is Python3 based so I install praw:
$ sudo pip3 install praw
[...]
Which went just fine as expected, but now when I import praw:
$ python3
Python 3.4.2 (default, Oct 8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import praw
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/praw/__init__.py", line 14, in <module>
from .reddit import Reddit # NOQA
File "/usr/local/lib/python3.4/dist-packages/praw/reddit.py", line 11, in <module>
from prawcore import (Authorizer, DeviceIDAuthorizer, ReadOnlyAuthorizer,
ImportError: No module named 'prawcore'
Even after manually adding the path to the module, I can't import praw.
>>> import sys
>>> sys.path.append('/usr/local/lib/python3.4/dist-packages/')
>>> import praw
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/praw/__init__.py", line 14, in <module>
from .reddit import Reddit # NOQA
File "/usr/local/lib/python3.4/dist-packages/praw/reddit.py", line 11, in <module>
from prawcore import (Authorizer, DeviceIDAuthorizer, ReadOnlyAuthorizer,
ImportError: No module named 'prawcore'
With python(2), it seems to be working just fine.
How can I get my system to successfully import praw?
From reddit.com/r/redditdev:
pip3 install praw --upgrade --force-reinstall
did the job. Apparently something went wrong during the initial installation.

Python 3.6.2 from urllib.request import urlopen

This is a script that I want to start to use. I have seen this as a working version on a few location. Any one has an idea why this will not execute on my mac system. I am open to all ideas to solve this issue.
from urllib.request import urlopen
html = urllib.request.urlopen("http://www.google.com")
print(html.read())
I get this as the output when executed.
Python 3.6.2 (v3.6.2:5fd33b5926, Jul 16 2017, 20:11:06)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>>
====== RESTART: /Users/John/Documents/python_function_john/scraping.py ======
Traceback (most recent call last):
File "/Users/John/Documents/python_function_john/scraping.py", line 1, in <module>
from urllib.request import urlopen
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 88, in <module>
import http.client
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 71, in <module>
import email.parser
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/email/parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/email/feedparser.py", line 27, in <module>
from email._policybase import compat32
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/email/_policybase.py", line 9, in <module>
from email.utils import _has_surrogates
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/email/utils.py", line 30, in <module>
import datetime
File "/Users/John/Documents/datetime.py", line 4
print a.time()
^
SyntaxError: invalid syntax
It is better that you install Anaconda; this application installs some Python package on your computer. Then write following line in Conda Prompt:
conda install -c conda-forge requests
After all, use Spyder application which has been installed with Anaconda.

Resources