Getting `python: command not found` at build

Hi, build for project 852d436d-dbcc-4eba-986d-bd7e01a98613 keeps on failing:
#13 0.389 /bin/bash: line 1: python: command not found

#13 ERROR: executor failed running [/bin/bash -ol pipefail -c python -m manage migrate --no-input]: exit code: 127
-----
> [stage-0 9/10] RUN --mount=type=cache,id=s/c556cde8-b8e0-4934-9b2a-486aafb6dac8-node_modules/cache,target=/app/node_modules/.cache python -m manage migrate --no-input:
-----
executor failed running [/bin/bash -ol pipefail -c python -m manage migrate --no-input]: exit code: 127

Error: Docker build failed
#13 0.389 /bin/bash: line 1: python: command not found

#13 ERROR: executor failed running [/bin/bash -ol pipefail -c python -m manage migrate --no-input]: exit code: 127
-----
> [stage-0 9/10] RUN --mount=type=cache,id=s/c556cde8-b8e0-4934-9b2a-486aafb6dac8-node_modules/cache,target=/app/node_modules/.cache python -m manage migrate --no-input:
-----
executor failed running [/bin/bash -ol pipefail -c python -m manage migrate --no-input]: exit code: 127

Error: Docker build failed
Where should I look for clues? Thank you
38 Replies
Percy
Percy2y ago
Project ID: 852d436d-dbcc-4eba-986d-bd7e01a98613,c556cde8-b8e0-4934-9b2a-486aafb6dac8
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP2y ago
I don't but I am indeed using Python in this project. And I have both a requirements.txt and pyproject.toml in the project's root.
root
root2y ago
Hmm, this is pretty strange. As a workaround, you could try setting NIXPACKS_PKGS (environment variable) to python311
Niccolò
NiccolòOP2y ago
It's weird 'cause I have another service that doesn't have any of that, and it works. Also, it would be nice for the system to pick up the Python version from the pyproject.toml's requires-python setting if present. Can't really find a solution to this, hopefully someone can shed some light as to why this is happening.
Brody
Brody2y ago
send me the link to your repo and ill have a look at it when i have some time
Niccolò
NiccolòOP2y ago
It's a private repo, gotta send you an invitation. Email address?
Niccolò
NiccolòOP2y ago
Sent, you should be able to join now.
Brody
Brody2y ago
okay ill have a look in a bit is this supposed to be a monorepo? @Niccolò
Adam
Adam2y ago
@Niccolò sounds like you didn’t do what aleks suggested here that’s the solution Some node packages require python to install them. Python isn’t automatically added as a provider in these cases
Brody
Brody2y ago
ive seen their repo, its a little more complicated than that unfortunately
Adam
Adam2y ago
eh if it wants python give it python if there’s more errors once that is solved we can take those on. one step at a time
Brody
Brody2y ago
as far as i can tell its a monorepo but with a lot of things out of place for example theres a package.json file at the root that pertains to a service thats 3 directories deep that doesnt have a package.json, it also lacks a start command, so lots of issues to work through with the first i think should be to get the directory structure setup properly
Adam
Adam2y ago
agreed
Niccolò
NiccolòOP2y ago
Nope, I did follow the suggestion, but I had more errors with Django not being found and, like I said, I have another project where everything works just fine without customizing the environment in any way. The FE is not a service in that repo, technically. FYI, the only different between the repo where Python is detected automatically and this one is the package.json in the root. I will move it away from the root and see how it fares. Yep, it's working. I guess the environment got really confused by the package.json in the root.
root
root2y ago
Yeah, it looks like the Node provider is tested before the Python provider, so if it sees a package.json, it'll think it's a Node app.
Niccolò
NiccolòOP2y ago
Frankly, I've often seen the package.json placed in the root folder in monorepos. Imo the pipeline should check whether, among the possible files used to detect an environment, only the package.json is present in the root. So, it went through the part of the build where it was failing before, but then failed because my project needs Python3.11. I therefore added python311 to NIXPACKS_PKGS but it fails again:
#8 32.96 error: collision between `/nix/store/9493ngfjwisjm5f5s5ld5m34rdy431ic-python3-3.8.16/lib/libpython3.so' and `/nix/store/xscl8kqmywwjvqv7l9i5j8xb4a9b655y-python3-3.11.1/lib/libpython3.so'
#8 32.96 error: collision between `/nix/store/9493ngfjwisjm5f5s5ld5m34rdy431ic-python3-3.8.16/lib/libpython3.so' and `/nix/store/xscl8kqmywwjvqv7l9i5j8xb4a9b655y-python3-3.11.1/lib/libpython3.so'
It's still installing Python 3.8 for some reason
Niccolò
NiccolòOP2y ago
Niccolò
NiccolòOP2y ago
Both NIXPACKS_PKGS=postgresql python311 and NIXPACKS_PKGS=postgresql,python311 do not work
Adam
Adam2y ago
Create a nixpacks.toml and manually set the packages you'd like to install
Adam
Adam2y ago
env variables are a bandaid fix, this is more permanent
Niccolò
NiccolòOP2y ago
thanks
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Adam
Adam2y ago
Read the docs I sent above and you'll be able to make your own
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Adam
Adam2y ago
Please send the nixpacks.toml you made
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Adam
Adam2y ago
Add “…” as a provider and setup package. This allows nixpacks to add auto detected packages as well also, pretty sure the provider is python3 not python you shouldn’t have to set an install command. Nixpacks will auto detect it And you’re overwriting the build command with nothing atm
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Adam
Adam2y ago
alright fair enough can you drop an ls before your start command?
angelo
angelo2y ago
Hey there, keeping an eye on everything here. Won't be able to get to this immediately but we are going to be working on a soltion for this.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
angelo
angelo2y ago
PRs welcome on our docs
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP2y ago
Sorry, I seldom log into this account. Did you manage in the end? Anyway, this is all I needed in the end (python311 is there to comply with specific requirements):
[phases.setup]
nixPkgs = ["gcc", "postgresql", "python311"]
[phases.setup]
nixPkgs = ["gcc", "postgresql", "python311"]
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server