Build error for Django + MySQL stack.
jonathan-h-grebe
FREEOP

5 months ago

Am trying to follow the Django deployment guide written for deploying via the cli with a postgres DB, but using MySQL instead.
I seem to have gotten the MySQL service added, and the environment variables set, but when I do railway up , the build fails.
The error seems to be caused by mysqlclient and mariadb not being there as packages on the virtual machine doing the build:

× Getting requirements to build wheel did not run successfully.

│ exit code: 1

╰─> [29 lines of output]

Trying pkg-config --exists mysqlclient

Command 'pkg-config --exists mysqlclient' returned non-zero exit status 1.

I've tried adding this nixpacks.toml to the project root, in order to make sure mysqlclient is installed in advanced, but that hasnt helped:

[phases.setup]
aptPkgs = ["...", "mysqlclient"]   # Install the wget package with apt-get

Does anyone have experience using django + mysql, particuarly when when using the cli?
My local env is windows 11.

$10 Bounty

1 Replies

nitish800
FREE

5 months ago

Looking at your error, the issue is that mysqlclient (the Python package for connecting Django to MySQL) requires certain system-level MySQL development libraries to compile during installation, but these aren't available in the Railway build environment.

Here are a few solutions to try:

Option 1: Install the correct system packages

Your nixpacks.toml approach is on the right track, but mysqlclient isn't an apt package - it's a Python package. You need the MySQL development headers and libraries. Try this instead:

[phases.setup]
aptPkgs = ["default-libmysqlclient-dev", "pkg-config", "gcc"]

Or alternatively:

[phases.setup]
aptPkgs = ["libmysqlclient-dev", "pkg-config", "build-essential"]

Loading...