no module name MySQLdb - python

I'm doing web scraping (I'm using miniconda) and I need to import the data that I got it using scrapy to a Mysql database but when I execute my program in Python 2.7 using Scrapy it says:
no module name MySQLdb
but I've installed the connection python mysql already so I don't know what is the problem...
Connector/Python 8.0.11 Windows (x86, 64-bit), MSI Installer Python
2.7
I went to shell python and I executed >>import MySQLdb to verify if it's installed correctly and it says
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import MySQLdb
ImportError: No module named MySQLdb
I've looking for other solution and I installed a lot of other versions of this connector mysql but it doesn't work
thanks in advance.

Related

No Module After Install Package via Canopy Package Management

I need help with the pyodbc Python module. I installed it via Canopy package management, but when I try to import it, I get an error (no module named pyodbc). Why?
Here's the output from my Python interpreter:
import pyodbc
Traceback (most recent call last):
File "", line 1, in
import pyodbc
ImportError: No module named 'pyodbc
For the record: the attempted import was in a different Python installation. It is never good, and usually impossible, to use a package which was installed into one Python installation, in another Python installation.

MARIADB - Python Connection Issue

Issue - On CENTOS 7, I have installed MARIADB 10.x which is working perfectly fine, I tested with DBeaver.
to connect MARIA DB 10.x from PYTHON 2.7, I have installed "MySQL-python 1.2.5" as recommended "https://mariadb.com/blog/how-connect-python-programs-mariadb".
But getting below error while testing, Please help with this.
import mysql.connector as mariadb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named mysql.connector
UPDATE
The lib MySQLdb1 is not maintained anymore. The MySQL company maintain a connector project.
Use MySQL Connector for Python as MariaDB database connection.
import MySQLdb as mariadb
conn = mariadb.connect(user='username', passwd='1a2b3c', db='defaultdb')
cursor = conn.cursor()
The lib mentioned on MariaDB docs is the one officialy builded by MySQL. Using this lib you will be able to follow the tutorial.
As #nizam-mohamed mentioned in comments, there is a a fork from MySQLdb1, mysqlclient.

Unable to connect MySQL and Python

I am using python 3.5 for school project, I also already installed MySQL connector for python. I tried to import the database from MySQL but it says "MySQL module not found.
import mysql.connector
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import mysql.connector
ImportError: No module named 'mysql'
How do i solve this? any idea?
is mysql connector installed with python pip 3.5 ?
sometimes default pip is binded to default python, make sure you've installed it for correct version of python

mysql-connector-python-2.0.2-py3.3.msi Installation failed

I want to use "import MySQLdb"
So I downloaded Windows (Architecture Independent), MSI Installer Python 3.3
Address :http://dev.mysql.com/downloads/connector/python/
After the installation is complete,tell me installation failed
import MySQLdb
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named 'MySQLdb'
Please tell me how to do。thx.
PS:I use MySQL Server 5.5 and python33
Take a look at any example in the documentation and you will find that the module coming with oracle's mysql connector is not named MySQLdb, but simply mysql (or rather mysql.connector):
import mysql.connector
cnx = mysql.connector.connect(user='scott', password='tiger',
host='127.0.0.1',
database='employees')
cnx.close()
From:
http://dev.mysql.com/doc/connector-python/en/connector-python-example-connecting.html

Wamp Server and Python

Hi i have installed WAMP server(Mysql , apache ,php) and also installed "Python" separately.Now i am trying to connect to that database using python code .
This is my python code:
#!C:\Python32\python.exe
import sys
import os
import cgi
import MySQLdb
import cgitb
import SecureDb
cgitb.enable()
print ("Content-type: text/plain\n\n");
conn= MySQLdb.connect(host = SecureDb.host ,user =SecureDb.user ,passwd=SecureDb.password ,db=SecureDb.database)
cursor=conn.cursor()
cursor.execute("select * from register where Name='Subburaj'")
result=cursor.fetchall()
cursor.close()
conn.close()
But this is showing an error:
Traceback (most recent call last):
File "C:\Users\Ponmani\Desktop\test.cgi", line 5, in <module>
import MySQLdb
File "C:\Python32\lib\site-packages\MySQLdb\__init__.py", line 17, in <module>
from release import __version__, version_info, __author__
ImportError: No module named release
If anybody came across this problem please help me to solve this.Thanks in advance.
MYSQLdb doesn't come with python. It seems that you have to install it first from here. There's an executable here, if you are using windows 32. But it's for python 2.7. If you are using python 3.2 it gets more difficult. Here's an unofficial package that should work for 3.2.
EDIT:
Release module should be a part of mysqldb, my only guess is theres is still something wrong with the installation. Maybe subforlders weren't extracted correctly.You should try to reinstall.
EDIT: you can also check if you have release.py in the mysqldb directory. if you dont it is surely installation problem.
You Need to install MySQLdb Module
easy_install MySQL-python

Categories

Resources