80
Try to run this before:
Ubuntu:
sudo apt-get install python-dev python3-dev
sudo apt-get install libmysqlclient-dev
pip install pymysql
pip install mysqlclient
In OSX:
sudo xcodebuild -license accept
brew install mysql-connector-c
5
This is probably due to your mysql_config
being broken.
As of 2019, here is how to run smoothly pip install mysqlclient
on MacOS:
brew info openssl
and follow the commands at the bottom
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.zshrc
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
Other approaches:
brew install/upgrade/reinstall mysql
: did not fix the issue for me, but has the nice side effect to make sure your installation is clean.brew install mysql-connector-c
: to make that work you have to unlink mysql, which ruins your setup and it did not fix the issue for me.
- [Django]-Internal Server Error with Django and uWSGI
- [Django]-Select between two dates with Django
- [Django]-Django Rest Framework: turn on pagination on a ViewSet (like ModelViewSet pagination)
2
If youโre using Anaconda (which I highly suggest you) then run these two commands
conda install -c anaconda mysql-connector-python
and
conda install -c bioconda mysqlclient
- [Django]-Naming Python loggers
- [Django]-Django โ Reverse for '' not found. '' is not a valid view function or pattern name
- [Django]-Do properties work on Django model fields?
1
-
Download the MySQL APT repository config tool (you can see more details here: http://dev.mysql.com/downloads/repo/apt/)
wget http://dev.mysql.com/get/mysql-apt-config_0.7.3-1_all.deb
-
Install the MySQL APT repository config tool
dpkg -i mysql-apt-config_0.7.3-1_all.deb
You will be asked to select product and version that you want to install. In the first step, select Server and next select either mysql-5.6 or mysql-5.7. Then click Apply.
-
Update APT
apt-get update
-
Install the server
sudo apt-get install mysql-community-server sudo apt-get install python-dev python3-dev sudo apt-get install libmysqlclient-dev pip install pymysql pip install mysqlclient
- [Django]-Django model one foreign key to many tables
- [Django]-Django Order By Date, but have "None" at end?
- [Django]-How to override and extend basic Django admin templates?
1
If you are using Python 2.x, and already have installed:
- MySQL Server
- Python Connector
Then the problem is when you run:
Windows:
(your environment) SomePath> pip install mysqlclient
Mac OS:
$ pip install mysqlclient
Actually it is asking to install package for Python 3.x not 2.x. So it is throwing an error.
Solution is to run:
Windows:
(your environment) SomePath> pip install mysqlclient==1.3.9
Mac OS:
$ pip install mysqlclient==1.3.9
P.S The mysqlclient==1.3.9 version is the latest version for Python 2.x
- [Django]-Easily rename Django project
- [Django]-Get list of Cache Keys in Django
- [Django]-Update all models at once in Django
0
For Ubuntu 18.04
sudo apt-get install python-dev python3-dev
sudo apt-get install libmysqlclient-dev
pip install pymysql
pip install mysqlclient
and setup
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'DB_NAME',
'USER': 'DB_USER',
'PASSWORD': 'DB_PASSWORD',
'HOST': 'localhost', # Or an IP Address that your DB is hosted on
'PORT': '3306',
}
}
- [Django]-Can WordPress be replaced by a Framework like Django or Ruby on Rails?
- [Django]-How to use regex in django query
- [Django]-Serving large files ( with high loads ) in Django
0
This worked for on Ubuntu 18.04
sudo apt-get install python3.6-dev
sudo apt-get install mysql-client
sudo apt-get install libsqlclient-dev
sudo apt-get install libssl-dev
- [Django]-Custom django admin templates not working
- [Django]-Django sending email
- [Django]-Django โ why is the request.POST object immutable?
0
This worked for me on Python 3.12 and Ubuntu 22.04 WSL.
sudo apt-get install -y python3-dev
sudo apt-get install -y gcc default-libmysqlclient-dev pkg-config
pip install mysqlclient
- [Django]-Django ALLOWED_HOSTS IPs range
- [Django]-Passing STATIC_URL to file javascript with django
- [Django]-Dynamically exclude or include a field in Django REST framework serializer