Python mysql.connector.pooling ImportError: No module named pooling - python

I am facing some difficulty when I try to run a Flask app. I get the following import error:
File "/db/mysql_utils.py", line 2, in <module>
import mysql.connector.pooling
ImportError: No module named pooling
I tried several ways to install mysql_connector_python-1.0.12 such as
sudo pip install https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-1.0.12.tar.gz
Download the file to local and install it. Also tried running the setup.py and had no luck.
I am assuming mysql.connector.pooling is part of mysql-connector-python, but please correct me if I am wrong.
Thanks

On my Centos7 box, i installed the community-release repo and mysql-connector.
sudo yum update mysql-community-release
sudo yum install mysql-connector-python
https://dev.mysql.com/doc/connector-python/en/connector-python-installation-binary.html

Related

ModuleNotFoundError: No module named 'psycopg2' (But it is installed)

I've been stuck on a part of a Udemy course. Even the (very helpful) tutor on there has run of ideas. When I try and run my script I get:
ModuleNotFoundError: No module named 'psycopg2'
I've done pip install psycopg2 and pip install psycopg2-2.8.4-cp37-cp37m-win_amd64.whl. Both result in 'requirement already satisfied'. I tried CTRL+SHIFT+P, Select Interpreter, and got the same problem with all of the three options. Only difference is Python3.8.0 gives me a Unable to import 'psycopg2' pylint(import-error) [1,1] error as well.
C:\Python\Database>pip install psycopg2
Requirement already satisfied: psycopg2 in c:\users\jeff\anaconda3\lib\site-packages (2.8.4)
C:\Python\Database>script1.py
Traceback (most recent call last):
File "C:\Python\Database\script1.py", line 1, in <module>
import psycopg2
ModuleNotFoundError: No module named 'psycopg2'
Edit
I still can't figure this out. And now I just got the same problem with Tweepy. ModuleNotFoundError: No module named 'tweepy' after I'd just successfully installed it. And similar error in the problems tab on VSC Unable to import 'tweepy' pylint(import-error) [1,1].
Psycopg project has modified the way they distribute the package. Starting from version 2.8.0, psycopg2 wheel on Pypi is a source distribution. To get the same package you used to install, you have to
pip install psycopg2-binary
Explanations can be found in psycopg-2.7.4 release note:
The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: </docs/install.html#binary-install-from-pypi>.
I guess you need to first install the dependencies.
sudo apt-get install build-dep python-psycopg2
Now run
pip install pyschopg2
I had a similar issue. I solved it by installing psycopg2 using PyCharm UI as follows :
Go to Current interpreter at the bottom of the window
Python Interpreter
Interpreter Settings
Interpreter Settings
Press (+) to add a package
Add package
Type psycopg2 on the search bar and press Install Package at the botton
Install psycopg2

Issue installing zenipy, ModuleNotFoundError: no module named 'gi'

I'm trying to import zenipy for windows 10 after reading and experiencing that zenity-python simply will not work. So I installed zenipy and got the 'successfully installed' message from the command line but now when trying to import it I get :
ModuleNotFoundError: No module named 'gi'
in PyCharm I am writing:
from zenipy import *
Please can someone help me to import zenipy and tell me what is going wrong?
Looks like it's not installed or don't have the dependencies that need. Try pip uninstall zenipy and then pip install zenipy.
Or download and install the repo on GitHub.
$ git clone https://github.com/poulp/zenipy.git
$ cd ./zenipy
$ python setup.py install

ModuleNotFoundError: No module named 'python_jwt' (Raspberry Pi)

I can't import correct Firebase package in Raspberry PI.
My code:
from firebase import firebase
db = firebase.FirebaseApplication("https://xyz.firebaseio.com/", None)
Error:
Traceback (most recent call last):
File "datastorage.py", line 1, in <module>
from firebase import firebase
firebase/__init__.py", line 14, in <module>
import python_jwt as jwt
ModuleNotFoundError: No module named 'python_jwt'
I tried to use this commands and it didn't help:
sudo pip install requests
sudo pip install python-firebase
pip install jwt
I use Python 3.7.3 and Raspbian Buster. All works on my PC but not on RPi 3B+.
I used advice from #naive.
pip install python_jwt
After that I solved another errors in that order:
pip install gcloud
pip install sseclient
pip install pycrypto
pip install requests-toolbelt
And now I see that It works. Problem was solved.
I think you need python_jwt instead of jwt. You can do:
pip install python_jwt
If you're referring to this library:
https://pyjwt.readthedocs.io/en/latest/
Then you need to install like this:
pip install PyJWT
And afterwards this will work:
import jwt

ImportError: No module named absl.testing

I've been trying to run the Object detection API, at the point to test if the instalation worked:
python object_detection/builders/model_builder_test.py
I got the following error:
File "object_detection/builders/model_builder_test.py", line 18, in <module>
from absl.testing import parameterized
ImportError: No module named absl.testing
I couldn't find a solution anywhere. Already tried pip install absl-py and pip3 install absl-py but without success.
Hope you could help me.
Got it working by using python3 object_detection/builders/model_builder_test.py
instead of python object_detection/builders/model_builder_test.py. I forgot that I was using TF for python3.
First install absl-py by running command if you are using tensorflow
with python3
sudo pip3 install absl-py
otherwise
sudo pip install absl-py
After that run
python3 object_detection/builders/model_builder_test.py
Cheers, You done it !!

Python urllib3 error - ImportError: cannot import name UnrewindableBodyError

I set my cronjob to call my script at particular time(ex- 2 4 5 10 * python3 mayank/exp/test.py).
When my test.py is called I'm activating the virtualenv within my test.py script as follows.
activate = "/home/myserver/schedule_py3/bin/activate_this.py"
exec(open(activate).read())
After activating the virtual environment(which has python3 in it and the packages needed to run the script), I'm trying to import requests it is showing me error as:-
File "schedule_module/Schedule/notification_task.py", line 2, in <module>
import requests
File "/usr/lib/python2.7/site-packages/requests/__init__.py", line 43, in <module>
import urllib3
File "/usr/lib/python2.7/site-packages/urllib3/__init__.py", line 10, in <module>
from .connectionpool import (
File "/usr/lib/python2.7/site-packages/urllib3/connectionpool.py", line 31, in <module>
from .connection import (
File "/usr/lib/python2.7/site-packages/urllib3/connection.py", line 45, in <module>
from .util.ssl_ import (
File "/usr/lib/python2.7/site-packages/urllib3/util/__init__.py", line 4, in <module>
from .request import make_headers
File "/usr/lib/python2.7/site-packages/urllib3/util/request.py", line 5, in <module>
from ..exceptions import UnrewindableBodyError
ImportError: cannot import name UnrewindableBodyError
As I can see that it is taking python2.7. Can anyone tell me where I'm wrong?
Note- I had installed all the packages using pip3 inside my virtual environment.
exceptions import UnrewindableBodyError ImportError: cannot import
name UnrewindableBodyError
The above error is likely due to "urllib3" package being broken. uninstall/install will fix the problem:
sudo pip uninstall urllib3
sudo pip install --upgrade urllib3
Another issue could be that, urllib3 was installed via pip, and requests installed via yum repo, or vice-versa. In that case, the fix is to completely remove these libraries and install it via same repo.
I recommend pip over yum to install both packages as it is easy to maintain and gives more control. Any further yum updates required for OS patching or VM maintenance activities etc., won't impact the packages installed via pip.
First remove all installations of “urllib3” and “requests” via pip and yum:
sudo pip uninstall urllib3 -y
sudo pip uninstall requests -y
sudo yum remove python-urllib3 -y
sudo yum remove python-requests -y
Now install both packages only via pip:
sudo pip install --upgrade urllib3
sudo pip install --upgrade requests
To install both packages only via yum:
sudo yum install python-urllib3
sudo yum install python-requests
Note: Always use virtual environment to avoid conflicts when an yum update happens at OS level.
You might want to look at your method of activating the virtual environment instead.
A good example can be found here
an example of this would be:
ex- 2 4 5 10 * /home/myserver/schedule_py3/<PATH TO VIRTUALENV PYTHON> <FULL PATH TO SCRIPT>mayank/exp/test.py
Because you use system python instead of virtualenv'ed.
First use activate, then python from your env folder.
2 4 5 10 * source /home/myserver/schedule_py3/bin/activate_this.py && python something_else.py
I was getting a slightly different error:
cannot import name 'HTTPConnectionPool' from 'urllib3.connectionpool'
It was getting caused b/c I had a file named queue.py in my app.
env/lib/python3.7/site-packages/urllib3/packages/six.py from urllib3 was trying to run
import queue
but instead of importing the right queue.py, was importing my queue.py!
I renamed my queue.py to something else and this seemed to resolve the issue.
in my server, we had install all the package using root privilege, but use in other account. I had encounter this kinds of error.
the way to resolve by:
sudo chmod 755 -R /usr/lib/python2.7/site-packages/
cheers
Oliver

Categories