python: can't open file '/app/main.py': [Errno 2] No such file
hqrobirto
FREEOP

a month ago

I cannot resolve this issue; the service is unable to update and run new modifications after updating the files.

Attachments

Solved$10 Bounty

4 Replies

Status changed to Open Railway about 1 month ago


shanmukha73
HOBBY

a month ago

Bro this error means your container can’t find main.py at /app/main.py. It’s not a Python issue, it’s a path/deployment problem.

Do this step by step:

  1. First check if the file even exists inside container: docker exec -it <container_id> sh ls /app → If main.py is not there, that’s the issue
  2. Check your project structure Make sure main.py is actually inside your project root (or wherever you're copying from)
  3. Fix Dockerfile (very important) It should look like: WORKDIR /app COPY . . CMD ["python", "main.py"]
  4. Rebuild properly (your issue is probably old container running): docker-compose down docker-compose build --no-cache docker-compose up -d
  5. If using volumes: volumes:
    • .:/app → then your local folder MUST have main.py

Most likely your container is using old build or wrong path. Rebuild clean and it’ll work.

If still not working, send me your Dockerfile + folder structure.


robzlabz
HOBBY

a month ago

rename main files into main.py


shanmukha73

Bro this error means your container can’t find `main.py` at `/app/main.py`. It’s not a Python issue, it’s a path/deployment problem. Do this step by step: 1. First check if the file even exists inside container: docker exec -it <container\_id> sh ls /app → If main.py is not there, that’s the issue 2. Check your project structure Make sure main.py is actually inside your project root (or wherever you're copying from) 3. Fix Dockerfile (very important) It should look like: WORKDIR /app COPY . . CMD \["python", "main.py"\] 4. Rebuild properly (your issue is probably old container running): docker-compose down docker-compose build --no-cache docker-compose up -d 5. If using volumes: volumes: * .:/app → then your local folder MUST have main.py Most likely your container is using old build or wrong path. Rebuild clean and it’ll work. If still not working, send me your Dockerfile + folder structure.

hqrobirto
FREEOP

a month ago

I deleted most of the files and rewrote them, but the problem persists. Realway.com can't find the main.py file.

Attachments


jasperfrontend
HOBBY

a month ago

still not railway's fault. you said you "deleted most of the files" that doesn't help us at all. Show a screenshot of your project folders. the error clearly says there is no such file in /app/main.py so check your /app folder to see if main.py is in there.

Hint: It's not.


Status changed to Solved hqrobirto about 1 month ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...