In my python application i am using the matplotlib.when i start running it throws me an error:
ImportError: No named '_tkinter', please install the python3-tk package
Then i have installed sudo apt-get install python-tk.It got works in localhost.But same app i am deploying into the google cloudPlatforms.But i am getting this error:
import _tkinter # If this fails your Python may not be configured for Tk ImportError: libBLT.2.5.so.8.6: cannot open shared object file: No such file or directory
How to install python-tk to Google cloudPlatforms.After deactivate the vitualenv also i have installed.It shows already the newest version.I have tried many things but it doesn't seems to work.The App throws 502 Bad Gateway.
Thanks in advance.
Use
matplotlib.use('agg')
right after importing matplotlib, to render matplotlib graphics in a headless environment. You can also set this as the default in your matplotlibrc file, or via the MPLBACKEND environment variable.
See the matplotlib docs for more details: https://matplotlib.org/faq/usage_faq.html#what-is-a-backend See also the page on using matplotlib in a web application.
Related
I'm trying to connect my python scripts to an MySQL or MariaDB Server on my RaspberryPi4.
My python script right now just contains import mysql.connector. But when I try to start it via sudo python3 startdb.py I just get import mysql.connector ModuleNotFoundError: No module named 'mysql' as an error.
I get an other error, when I start the script via sudo python startdb.py: import mysql.connector ImportError: No module named mysql.connector.
I searched for a solution on many sites or forums. I mostly just found various versions of pip install mysql-connector-python (also with pip3, mysql-connector-python-rf or mysql-connector) to run but none of them worked for me. The only difference I recognized is that I previously got the error ModuleNotFoundError with both sudo python and sudo python3, but now I only get it with sudo python3.
Does anyone know how to solve this?
Could the fact that my script isn't in a sub-directory of /home/pi/, but instead of /home/, be the problem?
Edit: I just tried executing the script via the desktop mode using my mouse and just clicking on run and it worked. But when I'm using the command line in desktop mode or with a SSH session it doesn't work.
Another Edit: It looks like when I'm starting the script without sudo it'll work just fine. Don't actually know why's that, but I'm good for now. But would be very interesting to know and understand why the sudo makes it "crash".
Thanks and happy to hear some solutions :D
Cooki
raspbian give user mode in running, just in Desktop gives some permission to user for run app as root to access all necessary attributes , use sudo with all initial steps when you download and install project package's
i'm having this error could someone help me with it.
File "/Users/king/Desktop/dash1-env/DASH/lib/python3.7/site-packages/rest_framework_social_oauth2/views.py", line 7, in
from oauth2_provider.ext.rest_framework import OAuth2Authentication
ModuleNotFoundError: No module named 'oauth2_provider.ext'
I was facing the same error.
Here is the solution:
pip install django-rest-framework-social-oauth2
instead of:
django-rest-framework-social-oauth2==1.0.4
...this version caused the error
(I'm guessing outh2_provider.ext is a module)
The ModuleNotFoundError comes if you did not properly download the module, not download it at all, or mistyped it.
Go to the terminal inside of your script editor or IDE
to download with python 3 and above:
pip3 install OAuth2 Provider
to download with python 2:
pip install OAuth2 Provider
It should download and the at the top instead of import oauth2_provider.ext you write:
import oauth2
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.
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.
I tried to run a nltk code for drawing parse trees. I got the error that tkinter module is not installed.
These are the error messages I got:
1. UserWarning: nltk.draw package not loaded (please install Tkinter library).
warnings.warn("nltk.draw package not loaded")
2. import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
After some searches I installed the ActiveTcl 8.5.18.0 using this instructions.
But when I try to run my code I still get the sam error. I tried
import Tkinter
but I get the second error message above again.
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
I also looked at Tkinter documentations and it is mentioned that the correct installation of Tkinter can be verified by running the following command which again gives me another error.
command: python -m tkinter
error: /usr/local/opt/python/bin/python2.7: No module named tkinter
I found this answers on Stackoverflow for my problem but they are either not very clear or not applicable to my case.
How to get tkinter working with Ubuntu's default Python 2.7 install?
Problems: tk-dev is not available for OS X (it is same as ActiveTcl) and I couldn't figure out how to rebuilt my python using make
Tkinter: "Python may not be configured for Tk"
Problems: very vague. I don't know what should I do
please help.
You should install ActivePython rather than ActiveTcl, and use it as your preferred Python.
The problem is your Python install isn't picking up your Tcl install, and the simplest way to solve that is to install a Python version that is configured for Tk, which ActivePython is: http://www.activestate.com/activepython
The issue is that the _tkinter Python module is not installed in your build, which is a required bridge between Python and Tk. You will have to reinstall nltk and any other packages you are using, unfortunately, as the versions you have will be installed for your current Python and not your new one.
I'm trying to deploy django in AWS ElasticBeanstalk.
While I was following the steps as shown here, I'm stuck with the command, "eb init".
I'm using Python 2.7 in Ubuntu 12.10 (vmware)
I'm getting the error as below:
eb init
.....
from lib.aws.http_client import HTTP_GET, HTTP_POST
File "/home/g/Documents/Files/AWS/AWS-ElasticBeanstalk-CLI-2.4.0/eb/linux/python2.7/lib/aws/http_client.py", line 17, in <module>
from httplib import HTTPSConnection
ImportError: cannot import name HTTPSConnection
Two possibilities spring to mind...
The Python installation on AWS doesn't include SSL support.
You've created a file called httplib.py which is shadowing the one in the standard Python library.
Try doing import ssl, and if you get ImportError: No module named _ssl, then it's #1, otherwise it's #2.
I had installed python via homebrew and was getting this error. For some reason the solution was to uninstall and reinstall it:
brew uninstall python
brew install python
I had the same problem with a virtual environment. I deleted the virtual environment and recreated it and the problem disappeared.