MYSQL- python pip install error

2024/7/27 11:07:34

I tried to get build an app on Django and I wanted to use MySQL as the database. After setting up the settings.py right, I tried to migrate. Then I got the obvious error saying that MySQL is not installed. So inorder to install MySQL, I ran:

sudo -H pip install MySQL-python

I get the following error:

    Collecting MySQL-pythonUsing cached MySQL-python-1.2.5.zipComplete output from command python setup.py egg_info:sh: mysql_config: command not foundTraceback (most recent call last):File "<string>", line 1, in <module>File "/private/tmp/pip-build-zAMhWo/MySQL-python/setup.py", line 17, in <module>metadata, options = get_config()File "setup_posix.py", line 43, in get_configlibs = mysql_config("libs_r")File "setup_posix.py", line 25, in mysql_configraise EnvironmentError("%s not found" % (mysql_config.path,))EnvironmentError: mysql_config not found----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-zAMhWo/MySQL-python/

How do I fix this?

Answer

MySQL-python

MySQL-3.23 through 5.5 and Python-2.4 through 2.7 are currentlysupported. Python-3.0 will be supported in a future release.

You can install mysqlclient or pymysql,I prefer the latter:

pip install pymysql

And add this to your manage.py:

import pymysql
pymysql.install_as_MySQLdb()
https://en.xdnf.cn/q/73072.html

Related Q&A

How to do a boxplot with individual data points using seaborn

I have a box plot that I create using the following command: sns.boxplot(y=points_per_block, x=block, data=data, hue=habit_trial)So the different colors represent whether the trial was a habit trial or…

Load QDialog directly from UI-File?

I work with QT Designer and create my GUIs with it. To launch the main program, I use this code:import sys from PyQt4 import uic, QtGui, QtCore from PyQt4.QtGui import * from PyQt4.QtCore import *try:_…

Is there a way to detect if running code is being executed inside a context manager?

As the title states, is there a way to do something like this:def call_back():if called inside context:print("running in context")else:print("called outside context")And this would …

Adding title to the column of subplot below suptitle

Is there a simple way to add in to my original code so that I can add another title to both column of my subplot? for example like somewhere in the pink region shown in the picture below.Someone refer…

Conditional Inheritance based on arguments in Python

Being new to OOP, I wanted to know if there is any way of inheriting one of multiple classes based on how the child class is called in Python. The reason I am trying to do this is because I have multip…

Slice endpoints invisibly truncated

>>> class Potato(object): ... def __getslice__(self, start, stop): ... print start, stop ... >>> sys.maxint 9223372036854775807 >>> x = sys.maxint + 69 >…

Selenium Webdriver with Java vs. Python

Im wondering what the pros and cons are of using Selenium Webdriver with the python bindings versus Java. So far, it seems like going the java route has much better documentation. Other than that, it s…

asyncio - how many coroutines?

I have been struggling for a few days now with a python application where I am expecting to look for a file or files in a folder and iterate through the each file and each record in it and create objec…

Calculating a 3D gradient with unevenly spaced points

I currently have a volume spanned by a few million every unevenly spaced particles and each particle has an attribute (potential, for those who are curious) that I want to calculate the local force (ac…

deleting every nth element from a list in python 2.7

I have been given a task to create a code for. The task is as follows:You are the captain of a sailing vessel and you and your crew havebeen captured by pirates. The pirate captain has all of you stand…