brownser
brownser

Reputation: 622

matplotlib.pyplot giving error 'ImportError: No module named Tkinter' on python 2.7

I'm using a remote machine for computation and data analysis. I don't have sudo access in this machine, for data analysis purposes I want to use python libraries such as vtk etc since pip is not installed in this machine, I set up a 'virtual-environment' and install VTK there, I used the method explained here (https://stackoverflow.com/a/13958308/10755782). Then I could install vtk in the virtual environment using pip.

But now the problem is that I can't import matplotlib.pyplot, it is giving me the error

ImportError: No module named Tkinter.

This error is strange because matplotlib.pyplot works in this particular system outside my virtual-environment. There are a few workarounds to start using matplotlib.pyplot without tkinter such as this (https://stackoverflow.com/a/49988926/10755782), but this is not helpfull in my case as this machine is remote-accessed and I need 'tkinter' to view the graphs on my screen.

I tried installing 'tkinter' inside my virtual-env, but I could not ( since we can't install 'tkinter' with pip and I don't have sudo access).

As I could not find any immediate solution to this problem anywhere I tried to fix this myself and I did the following,

inside my virtual environment, the version of matplotlib was 2.2.4 and outside it was 1.2.0 ( which is working fine). So I downgraded the version of matplotlib inside my virtual environment to 1.2.0 pip install 'matplotlib==1.2.0' --force-reinstall now I have the same version of matplotlib inside and outside the virtual env. But now, when I try import matplotlilb.pyplot as plt I'm getting the error

ImportError: /b/home/ipcms/rcheenik/Python_virt-env/python2.7/my_new_env/lib/python2.7/site-
packages/matplotlib/_cntr.so: undefined symbol: _intel_fast_memset

Is there any way to fix this ^^ error? any of these following will be able to help me. without OR is there any way to install tkinter without sudo ? or inside the 'virtual-environment' ?

OR is there any alternatives to matplotlib.pyplot which works without 'tkinter' and still display graphs remotely? ( not favourable, as I have to rewrite the entire code )

Thanks in advance for the help.

Upvotes: 1

Views: 604

Answers (1)

Aliflo
Aliflo

Reputation: 73

I found this answer to a similar question however, which I believe would solve your issue. https://stackoverflow.com/a/49988926/8775307 It imports matplotlib.pyplot without tkinter. I don't know if all the features are actually included though, so you'll have to test and let us know :).

You could always write to the administrator and request Tkinter - it's a widely used and useful package, so they might be willing to include it.

Upvotes: 1

Related Questions