ModuleNotFoundError: No module named 'mysql'| python-mysql - python

i have this error:
import mysql.connector
ModuleNotFoundError: No module named 'mysql'
I already install via pip3 mysql and mysql-connector
and of course also call import mysql.connector
im using xampp version 8.0.0 in my m1 I don't know if that will be the problem
pip3 list
error

Related

No module named 'pyrebase'

I cannot seem to get pyrebase to import, despite it being installed. I have ran this:
pip3 install pyrebase4
and it successfully installed, upon doing pip freeze I can see:
Pyrebase4==4.50
However, when I try import it using
import pyrebase
it just spits out the error:
ModuleNotFoundError: No module named 'pyrebase'
I'm at a loss and have no idea what to do

ModuleNotFoundError: No module named 'ldap'

I'm trying to query my openldap server and got error
ModuleNotFoundError: No module named 'ldap'
I already tried to install python packages:
pip install python-ldap
pip install pyldap
pip install ldap(got alot of errors for this one)
And I'm still can't run it.
the code is:
import ldap
con = ldap.initialize('ldap://192.168.14.129')
con.simple_bind_s("cn=Manager,dc=afik,dc=com","xxxxx")
ldap_base = "dc=afik,dc=com"
query = "(uid=hr_user1)"
result = con.simple_bind_s(ldap_base, ldap.SCOP_SUBREE, query)
the error that I getting:
[root#localhost GitShared]# python openldap.py
Traceback (most recent call last):
File "openldap.py", line 1, in <module>
import ldap
ModuleNotFoundError: No module named 'ldap'
[root#localhost GitShared]#
I'm using python 3.6 on a centos 7 machine.

Airflow:How do I use PyMySQL with MySQL Hook?

I am trying to use MySQL in Apache Airflow. I already use PymySQL to query MySQL databases and did not have MySQLDb installed. Thus I got the error:
from airflow.hooks.mysql_hook import MySqlHook
File "/anaconda3/anaconda/lib/python3.6/site-packages/airflow/hooks/mysql_hook.py", line 15, in <module>
import MySQLdb
ModuleNotFoundError: No module named 'MySQLdb'
If I go into mysql_hook.py class I already see they are using MySQLDB
import MySQLdb
import MySQLdb.cursors
What alternative I have other than importing pymysql manually instead of in a hook?
I am using Python 3.6
Thanks
In order for the MySQL hook to work in Airflow, you need to install the MySQL extra package. If you have installed Airflow with pip, then the following command will do:
pip install apache-airflow[mysql]
This will install the mysqlclient package, which is the one required here.

How to solve 'No module named pymysql'

I use computer that is Window 10 and my Python version is 3.6.
I installed pymysql and MySQLdb as in the picture below.
But When I tried to run python, I got this error : No module named 'pymysql'
also, MySQLdb...
How can I solved it?
Try to use pip3 install PyMySQL and import pymysql

Python not finding MySQLdb on OSX..?

Using pip I installed mysql-python, got:
Successfully installed MySQL-python-1.2.5
However when I try to import MySQLdb I get:
ImportError: No module named MySQLdb
locate MySQLdb gives me:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQLdb
Why is Python not finding the module?
Thanks!
Gil.

Categories

Resources