Every time I tried to run import matplotlib,
I have error ImportError: No module named Tkinter.
The output result is as listed below:
Python 2.7.5 (default, Aug 2 2016, 04:20:16)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 115, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 6, in <module>
from six.moves import tkinter as Tk
File "/usr/lib/python2.7/site-packages/six.py", line 203, in load_module
mod = mod._resolve()
File "/usr/lib/python2.7/site-packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/usr/lib/python2.7/site-packages/six.py", line 82, in _import_module
__import__(name)
ImportError: No module named Tkinter
I tried to install the tk.x86_64 and tk-devel.x86_64 packages, and tried to reinstall the python package but the error still appeared.
Also I tried to import Tkinter but I got the following error.
Python 2.7.5 (default, Aug 2 2016, 04:20:16)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named Tkinter
Does anyone have a workaround for this error?
I'm using python2.7.12 on ubuntu16.04.
I installed it with this command:
sudo apt-get install python-tk
I tried to install tkinter package for python2.7.5 from the following link:
tkinter package
Also I found there is dependency library libTix.so()(64bit) for tkinter package and i got it from the following link: libTix.so()(64bit) package
after that i installed both then I could import Tkinter and import matplotlib.pyplot as plt with no errors.
My 2 cents. Open a terminal and type the following.
$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
>>>
If you do not get an error like below then your Tkinter is fine and the problem is with matplotlib. Then try removing and reinstalling matplotlib.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named tkinter
I was getting the error "ImportError: No module named '_tkinter'" for python3.5 in-spite of installing python3-tk and tkinter-dev.
It showed the error in following file:
File "/usr/local/lib/python3.5/tkinter/init.py", line 35, in
import _tkinter # If this fails your Python may not be configured for Tk
It got resolved for me by simply running the python from /usr/bin like /usr/bin/python3.5 from terminal!
In short, please ensure the python version being run from terminal has the tkinter installed and configured :)
My PC configuration: Ubuntu16.04 with default python2.7 and python3.5
I faced the same issue on a RHEL 7 machine. There was no python-tk package that could be installed. I found the solution here which solved the issue for me:
sudo yum install tkinter
This should work for RHEL machines using Python 2.
Related
I have both python2.7 and python3.5 installed on Ubuntu 16.04. After I write import numpy in python2.7 environment, I get the following error,
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/usr/local/lib/python3.5/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python3.5/dist-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/local/lib/python3.5/dist-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python3.5/dist-packages/numpy/core/__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: cannot import name multiarray
But with python3 I am facing no such trouble with numpy. Please suggest a solution if anyone has faced similar issue.
you are importing a version of Numpy who are for python 3.5
you must download the version who are for 2.7
you can find the download packages of numpy as : http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
I have tensorflow already installed for Python 3.5 in Ubuntu 16.04, and when I import it, I get the following message:
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
/usr/local/lib/python3.5/dist-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
>>>
But with Python2.7, I get this:
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
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/python2.7/dist-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
>>>
I tried to install tensorflow after installing cuDNN, Cuda, bumblebee, nvidia driver etc., but after I rebooted, I couldn't get past the login screen. After a friend of mine fixed the problem, I still wanna use tensorflow with Python 2.7, how can I do so without messing up my system? I have cuda 9.1 installed.
Have you tried virtualenv to manage your pip packages? you can easily use it to avoid multi-version of tensorflow and Python,
Command Line activity Image
I have Python2.7 on windows.
Installed scheduler as
$pip install apscheduler==2.1.2
pip Listing shows the scheduler2.1.2
But keep getting:
U:\>python
Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from apscheduler.schedulers.blocking import BlockingScheduler
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named apscheduler.schedulers.blocking
>>> quit()
It look much cleaner in the image.
Thanks.
I have tried everything I found here at Stackoverflow. I have run out of options. What is wrong?
Praysons-MacBook-Pro:pyChrome praysondaniel$ pip install -U selenium
Requirement already up-to-date: selenium in /usr/local/lib/python2.7/site-packages/selenium-3.0.0b3-py2.7.egg
Praysons-MacBook-Pro:pyChrome praysondaniel$ python
Python 2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:33:12)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from selenium import webdriver
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named selenium
>>>
I have tried all other suggestion here including This ImportError: No module named 'selenium'.
>>> import sys; sys.path
['', '/Library/Frameworks/SQLite3.framework/Versions/C/Python/2.7', '/Library/Frameworks/GEOS.framework/Versions/3/Python/2.7/site-packages', '/Library/Python/2.7/site-packages/numpy-override', '/Library/Python/2.7/site-packages/matplotlib-override', '/Library/Frameworks/GDAL.framework/Versions/1.11/Python/2.7/site-packages', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', '/Library/Python/2.7/site-packages']
>>>
The only solution I came about is by creating a virtual Environment. Within my virtual environment, I pip install -U selenium and walla! It works
I'm having troubles installing python (2.7.6) modules in my Ubuntu 14.04 LTS. I have just tried to install module numpy (and others) and when I import it, I have the following output:
python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/numpy/__init__.py", line 153, in <module>
from . import add_newdocs
File "/usr/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 18, in <module>
from .polynomial import *
File "/usr/lib/python2.7/dist-packages/numpy/lib/polynomial.py", line 19, in <module>
from numpy.linalg import eigvals, lstsq, inv
File "/usr/lib/python2.7/dist-packages/numpy/linalg/__init__.py", line 50, in <module>
from .linalg import *
File "/usr/lib/python2.7/dist-packages/numpy/linalg/linalg.py", line 29, in <module>
from numpy.linalg import lapack_lite, _umath_linalg
ImportError: /usr/local/bin/gex/libgfortran.so.3: version `GFORTRAN_1.4' not found (required by /usr/lib/liblapack.so.3)
I already tried to update, upgrade, install with pip and so many other things and just became withouot extra options to try around here...
Could anyone give any light on what the problem might be?
Thanks in advance!
Cheers
Many thanks to everyone who read and tried to help, specially #jkalden. I managed to reinstall gfortran manually by downloading the package (deb file). Everything is working fine...so far...!
Once again, thank you all for the inputs.