[Python] linux/docker/python no such file or directory

Discussão em 'Python' iniciado por Stack, Dezembro 17, 2024.

  1. Stack

    Stack Membro Participativo

    I started rewriting software for Linux and found that python does not see files/folders in my computer. moreover, it does not see all folders / files, but some, (he began to dig into this, because he could not connect sqlite) although the permission of the entire directory with files is chmod 777, but this does not help, they still differ in some way apparently (I prescribe the absolute path, conditionally - /home/user/data/...) I issued chmod 777 to all directories and internals, tested various verification options in python itself, including os, sys, subprocess 'ls', but they do not see (although ls from the console sees conditionally)

    import subprocess

    file_path = '/home/user/data/logs'

    try:
    result = subprocess.run(['ls', file_path], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    print("yes")
    except subprocess.CalledProcessError:
    print("no")


    this code will return 'yes' but if the path is /home/user/data/database conditionally, it will return 'no'

    Dockerfile:

    # ------------- Dockerfile --------------

    FROM python:3.11-slim-buster

    RUN mkdir -p /usr/src/app

    WORKDIR /usr/src/app

    RUN pip install --no-cache-dir asyncio aiogram scheduler mysql-connector-python pydantic-settings APScheduler pytz asyncio-scheduler pyTelegramBotAPI loguru requests

    COPY . /usr/src/app

    CMD \["python", "./main.py"\]


    Paths:

    /home/lost0/data/database - doesn't work

    /home/lost0/data/logs - it works

    Continue reading...

Compartilhe esta Página