1
 FROM python:3.10
 
 COPY requirements.txt .

 RUN pip install -r requirements.txt
 #Make a copy of the current directory
 COPY / ./
 #Display list of files in directory
 RUN ls /
  
 ENTRYPOINT ["python", "/main.py"]

So this is my current dockerfile and the list displays as this when I build. Directory List

This is the code that is giving me the issue

d1 = open(r"backend_resources\results\orlando_averaged_2019-01-01.geojson")

And throwing me this error when I run the image

FileNotFoundError: [Errno 2] No such file or directory: 'backend_resources\\results\\orlando_averaged_2019-01-01.geojson'

However you will notice that in the image with the list, backend_resources and the other files within it do exist, and to my knowledge are in the correct directories for this code to run properly, still new to Docker so I definitely could be doing something wrong

  • Your slashes point in the wrong direction (assuming it's a Linux container); try forward slashes `backend_resources/results/...`, or `os.path.join()` to use whichever directory separator the local system uses. – David Maze Apr 10 '22 at 14:49

1 Answers1

0

I think problem is chosen path style. You use path in windows style. If you image based on unix system (Debian, Alpine, etc.), use path in unix style.

d1 = open(r"/backend_resources/results/orlando_averaged_2019-01-01.geojson")