ImportError: No module named MySQLdb
I am referring the following tutorial to make a login page for my web application. http://code.tutsplus.com/tutorials/intro-to-flask-signing-in-and-out—net-29982
I am having issue with the database. I am getting an
I have tried all possible ways to install python mysql, the one mentioned in the tutorial, easy_install, sudo apt-get install.
I have installed mysql in my virtual env. My directory structure is just the same as whats explained in the tutorial. The module is sucessfully installed in my system and still I am getting this error.
Please help. What could be causing this.
11 Answers 11
If you’re having issues compiling the binary extension, or on a platform where you cant, you can try using the pure python PyMySQL bindings.
Simply pip install pymysql and switch your SQLAlchemy URI to start like this:
There are some other drivers you could also try.
at the very beginning, i just installed MySQL-python, but the issue still existed. So i think if this issue happened, you should also take mysql-devel into consideration. Hope this helps.
I got this issue when I was working on SQLAlchemy. The default dialect used by SQLAlchemy for MySQL is mysql+mysqldb .
I got the » No module named MySQLdb » error when the above command was executed. To fix it I installed the mysql-python module and the issue was fixed.
It depends on Python Version as well in my experience.
If you are using Python 3, @DazWorrall answer worked fine for me.
However, if you are using Python 2, you should
which would install ‘MySQLdb’ module without having to change the SQLAlchemy URI.
So I spent about 5 hours trying to figure out how to deal with this issue when trying to run
With Ubuntu Server LTS 16.1, a full LAMP stack, Apache2 MySql 5.7 PHP 7 Python 3 and Django 1.10.2 I really struggled to find a good answer to this. In fact, I am still not satisfied, but the ONLY solution that worked for me is this.
followed by (from inside the virtual environment)
I really dislike having to use dev installs when I am trying to set up a new web server, but unfortunately this configuration was the only mostly comfortable path I could take.
Error loading MySQLdb module: No module named ‘MySQLdb’
I have tried a lot to solve this issue but I did not solve it. I have searched a lot on google and stackoverflow, no option is working for me. Please help me. Thanks in advance. I am using django 1.10, python 3.4. I have tried :
- pip install mysqldb.
- pip install mysql.
- pip install mysql-python.
- pip install MySQL-python.
- easy_install mysql-python.
- easy_install MySQL-python.
Anything else left ?
7 Answers 7
MySQLdb is only for Python 2.x. You can’t install in Python 3.x versions. Now from your question i can see that you are working with Django. In this case you have three alternatives, from Django mysql notes:
This gives to you two alternatives, mysqlclient and mysql-connect-python, The first one requires compilation from extensions for the plugin and, in Windows, this implies VStudio Libraries and a know-how for compile native extensions.
mysql-connect-python is not compiled (and i don’t recommend this for production, maybe only for dev) so you are going to need to install this.
if the first one fails.
MySQLdb is the interface to MySQL database. As mentioned by other posts, MySQLdb doesn’t support Python 3.x. I used PyMySQL as the replacement. You need to install it first:
The next step is to replace ‘MySQLdb’ with ‘pymysql’ in all the codes, which is intimidating. Luckily, PyMySQL can be loaded as MySQLdb dyanamically. In order to achieve it in Django, you need to add the following lines to __init__.py file under the dir of the project’s default app (If your have a project named ‘myproject’, add lines to myproject/myproject/init.py):
This __init__.py would be executed when you run the Django project, and MySQLdb will be replaced. You problem is then solved.
Не могу подключиться к MySql ( No module named ‘MySQLdb’ ). Где его взять для win?
Никак не могу подключиться к MySql!
Windows x64
Python 3.4
File » «, line 321, in _call_with_frames_removed
File «C:\Python34\lib\site-packages\django-1.7.6-py3.4.egg\django\db\backends\mysql\base.py», line 18, in
raise ImproperlyConfigured(«Error loading MySQLdb module: %s» % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named ‘MySQLdb’
Добавлено через 3 часа 54 минуты
Разобрался сам. Просто коннектор надо брать непосредственно с сайта MySQL.
Не могу импортировать модуль ImportError: No module named
Добрый день. есть такая иерархия: Project -main.py -Tests —negative.py —positive.py.
Где взять образ win xp для windows virtual pc?
Всем привет! нужен чистый образ win xp , для windows virtual pc. xp mode не подходит. слышал на.
После установки win 7 вместо win 8 не работают компьютер не видит флешки, не могу подключиться к интернету
Привет всем! Установил на ноутбук samsung windows 7 вместо родной восьмерки. При первом запуске.
PyQt5 Error while finding module specification for ‘PyQt5.uic.pyuic’ (ModuleNotFoundError: No module named ‘PyQt
В общем поставил pyqt5 и python3.7 пишу в консоль python -m PyQt5.uic.pyuic Выдает ошибку Error.
Заказываю контрольные, курсовые, дипломные и любые другие студенческие работы здесь.
При запуске скрипта PyCharm выдаёт «No module named Module»
Здравствуйте, товарищи формучане! Вчера начал изучать великолепный язык под названием Python и.
Где взять поставщик данных .Net Framework для MySQL
Имеется проблемка в виде отсутствия поставщика данных бд MySQL. Подскажите где скачать и как.
Просто подключиться к MySql взять с него данные.
Здраствуйте помоги пожалуйста. У меня есть MySqL (mysql-4.0.14a-win) нём есть база данных с.
No module named
Всем привет! Только начал изучать Python как сразу столкнулся с проблемой. Через pip install vk_api.
Где я могу взять простые тесты или лабораторные для усвоения знаний?
Подскажите пожалуйста, где я могу взять простые тесты или лабораторные для усвоения знаний.