Python not installing with deployment
Hello, I have a python package that serves both the backend and the FE of a web app. I am trying to deploy it. The build succeeds, but Railway never installs Python. Nixpacks only shows
npm
commands. And the final start
command fails because python was never installed. Details attached.
In the main root directory, I've got all the files that hint Python is needed: pyproject.toml
, poetry.lock
and requirements.txt
. The package does contain some node files, for tailwind.css and UI stuffs.
Any ideas on how to fix this?23 Replies
I just tried using the Heroku builder and it properly installed Python
So it's Nixpacks that's not picking it up
create a runtime.txt file with your current python version inside
in the format python-X.X.X
Since you’re using two languages you may have to use a specific nixpack, i’m not 100% sure how those behave. Set the NIXPACK_PCKGS environment variable to change those
using a package from here:
https://search.nixos.org/packages
@A Dumb thanks for the help. I created the runtime.txt file, but it didn't help. This is the only text in the file, assuming it's correct:
python-3.11.0
Yeah you’ll need to find a nixpack then, I don’t have any experience in that area, sorry
@A Dumb I don't even need the NPM stuff in production, it's just to pre-build the CSS stuff locally. So I don't want to remove it from Git, but is there an easy way to exclude the files/folders from build? Maybe that's easier
Setting NIXPACKS_PYTHON_VERSION may force nixpacks to use python. Setting a custom build command will let you exclude the files you don’t want
otherwise, maybe move the npm stuff to a different repo and gitignore it in your current folder structure. that’s the easy fix
Unfortunately, none of these solutions worked (I haven't tried removing Node code yet, that's a last resort... )
Setting these env variables don't force Nix to install python:
NIXPACKS_PYTHON_VERSION=3.10
NIXPACK_PCKGS=python310
And adding the runtime.txt
file with python-3.11.0
didn't solve it either.weird, I’m not sure then sorry
don’t have too much experience with wrangling nixpacks
All good, I really appreciate the ideas!
Hopefully someone else has ideas on how to solve it
Seem strange that Nixpacks wouldn't install python if it found all the prerequisites
Messaging here so I have visibility, will answer you problem soon
Thanks @Angelo !
I'm sure you're swimming in support tickets. so the TL;DR of my problem: I'm able to successfully deploy and run my app with the Heroku buildpack, but Nix fails because it doesn't install Python or any dependancies. It treats my Python package like a Node package.
I'm sure you're swimming in support tickets. so the TL;DR of my problem: I'm able to successfully deploy and run my app with the Heroku buildpack, but Nix fails because it doesn't install Python or any dependancies. It treats my Python package like a Node package.
Swimming is an understatement lol- lets see what we can do here.
Project Id?
34108dc5-7795-469f-b853-2863bbedfa6f
If you can, can ya share a GitHub repo?
also, do you have a procfile?
The repo is private, but yes, I do have a procfile
I’m using Starlite, which is an ASGI framework similar to FastAPI
If that helps
Does indeed!
Here’s the main directory structure
Oh that package.json is sure going to throw us for a loop
lemme talk with our engineers here
Thx! It’s just for tailwind CSS and some UI components.
I don’t actually need NPM in prod. But either way… shouldn’t NIX install both node packages and Python? Not sure why it ignores Python.
While heroku picks it up
Yep- just knocked out some other cases. Digging in, you may see some failed builds. Don't be alarmed, that is me.
Okay @Railay - so apparently the heroku buildpacks would prioritize Python over Node in the install order. We do the opposite, hence the bug.
the fix is making a
nixpacks.toml
with the following contents
This should solve your issues going forward@Angelo thanks! That seems to solve it, much appreciated 🙏
Woo hoo!
Btw, I’ve been using railway for ~12 hours now and I love it. Amazing product so far, kudos to you and the railway teams!