/bin/bash: line 1: python: command not found

I'm facing an issue while deploying my Django project on Railway. The deployment logs show the error message "/bin/bash: line 1: python: command not found," even though I have both a requirement.txt file and a runtime.txt file in my project. I'm unsure about the cause of this problem and would appreciate some guidance from a professional developer. Project id: 50a5c2a5-ff5d-45f0-b4e1-b8e9b312ab96
Solution:
i dont have your code to test with, so this is untested, but let me know how it goes ```json { "$schema": "https://railway.app/railway.schema.json", "build": {...
Jump to solution
35 Replies
Percy
Percy2y ago
Project ID: 50a5c2a5-ff5d-45f0-b4e1-b8e9b312ab96
Brody
Brody2y ago
do you happen to have a package.json in your project too?
Bilal Khan
Bilal KhanOP2y ago
Yes I do
Brody
Brody2y ago
then railway is detecting your project as a node js project and installing node instead of python. why do you have a package.json?
Bilal Khan
Bilal KhanOP2y ago
I am using flowbite and tailwind Whats the work around
Brody
Brody2y ago
a modifyed railway.json file
Bilal Khan
Bilal KhanOP2y ago
Thanks for your quick replies. Much appreciated
Brody
Brody2y ago
I can do this for you, but I'm about to eat dinner, so I'll get back to you later
Bilal Khan
Bilal KhanOP2y ago
oh great. Enjoy your dinner. Its morning time here in Australia.
Brody
Brody2y ago
am back, please send me your current railway.json file, every deployment has one, even failed deployments, it is located in the details tab of a deployment
Bilal Khan
Bilal KhanOP2y ago
ok I do have railway.json file in my repo
Brody
Brody2y ago
oh perfect, send that then
Bilal Khan
Bilal KhanOP2y ago
{ "$schema": "https://railway.app/railway.schema.json", "build": { "builder": "NIXPACKS" }, "deploy": { "startCommand": "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn webapp.wsgi", "restartPolicyType": "ON_FAILURE", "restartPolicyMaxRetries": 10 } }
Brody
Brody2y ago
fwiw you can enclose multi-line code in triple backticks
Solution
Brody
Brody2y ago
i dont have your code to test with, so this is untested, but let me know how it goes
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"nixpacksPlan": {
"providers": ["python"],
"phases": {
"setup": {
"nixPkgs": ["...", "nodejs"]
}
}
},
"buildCommand": "npm ci"
},
"deploy": {
"startCommand": "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn webapp.wsgi",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"nixpacksPlan": {
"providers": ["python"],
"phases": {
"setup": {
"nixPkgs": ["...", "nodejs"]
}
}
},
"buildCommand": "npm ci"
},
"deploy": {
"startCommand": "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn webapp.wsgi",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
Bilal Khan
Bilal KhanOP2y ago
you are a legend. thank you heaps . let me test this. Update you soon. It worked thank you so much . very helpful.
Brody
Brody2y ago
awsome, glad i could help!
Bilal Khan
Bilal KhanOP2y ago
I owe you a coffee
Brody
Brody2y ago
haha thanks
Bilal Khan
Bilal KhanOP2y ago
so what did you do in the railway.txt
Brody
Brody2y ago
overrode the provider back to only python since your main app is python, then added node js as a package, installed the node dependencies with the npm ci build command, and left the start command in tact theres no documentation for this exact use case, ive just used vscode with the schema auto complete
Bilal Khan
Bilal KhanOP2y ago
lol thats amazing whats your background? are you a developer?
Brody
Brody2y ago
not professionally, just for fun as odd as it may sound, i dont really have a background
Bilal Khan
Bilal KhanOP2y ago
oh ok have you worked with django?
Brody
Brody2y ago
zero django experience
Bilal Khan
Bilal KhanOP2y ago
lol ok whats your strength?
Brody
Brody2y ago
helping people with their railway issues
Bilal Khan
Bilal KhanOP2y ago
ok cool Thats very kind of you well I know where to come when I need help with railway
Brody
Brody2y ago
you sure do!
holy shnikes
holy shnikes2y ago
I'm having this exact same issue for my Django app for which I'm using React as the frontend (so have a package.json). @Brody , you mentioned please send me your current railway.json file, every deployment has one, even failed deployments, it is located in the details tab of a deployment I can't seem to find the details tab or the railway.json file. Has it moved by chance?
Brody
Brody2y ago
it hasn't moved, but you may be able to use the railway.json file I sent above, just with a slight modification to the start command
holy shnikes
holy shnikes2y ago
Ah thanks! I see, I just add it to my repo. Will try that when I get home later! And will modify the start command accordingly
Brody
Brody2y ago
perfect, but if you are still facing issues in the future I ask that you open a new thread as to avoid spamming the OP with notifications
MIGHTY_MIDHUN
MIGHTY_MIDHUN16mo ago
Thanks Brody Very much this helped me now. I was also facing the same issue. i just copy pasted your railway.json and it started working for me <:meow_wine:802401834643882034>
Brody
Brody16mo ago
Awesomeness
Want results from more Discord servers?
Add your server