
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
How do I Install MySQLdb in Python?
Before proceeding, you make sure you have MySQLdb installed on your machine. Just type the following in your Python script and execute it −
#!/usr/bin/python import MySQLdb
If it produces the following result, then it means MySQLdb module is not installed −
Traceback (most recent call last): File "test.py", line 3, in <module> import MySQLdb ImportError: No module named MySQLdb
To install MySQLdb module, use the following command −
For Ubuntu, use the following command - $ sudo apt-get install python-pip python-dev libmysqlclient-dev For Fedora, use the following command - $ sudo dnf install python python-devel mysql-devel redhat-rpm-config gcc For Python command prompt, use the following command - pip install MySQL-python
Note − Make sure you have root privilege to install above module.
- Related Articles
- How to install Python MySQLdb module using pip?
- How do I install Python SciPy?
- How do I Install Python Packages in Anaconda?
- MySqldb Connection in Python
- How do I install selenium latest version?
- How do we use easy_install to install Python modules?
- How I can install unidecode python module on Linux?
- How can I do "cd" in Python?
- How do I write JSON in Python?
- How do I use method overloading in Python?
- How do I delete a file in Python?
- How do I cache method calls in Python?
- How do I program using threads in Python
- How do I copy a file in python?
- How do I create a constant in Python?

Advertisements