본문 바로가기
개발 Error

[Docker] container Exec 발생 에러 모음

by doraemin_dev 2025. 2. 26.

main.py 실행 코드

cd app
python -m app.main

File "/app/app/main.py", line 4, in <module>
    from app.routers import auth, mypage, description, chat, conversation
ModuleNotFoundError: No module named 'app'

현재 디렉토리 구조를 보면 app/main.py에서 app.routers를 import하는데,
Python이 app을 최상위 모듈로 인식하지 못해서 발생하는 문제입니다.

아래 명령어를 실행하여 app 폴더를 Python 모듈 경로로 등록하세요.

 
export PYTHONPATH=/app python -m app.app.main

설명:

  • export PYTHONPATH=/app → /app을 Python이 모듈을 찾는 경로에 추가
  • python -m app.app.main → main.py를 모듈 방식으로 실행

File "/app/app/routers/auth.py", line 19, in <module>
    from app.config import KAKAO_API_KEY, KAKAO_REDIRECT_URI #, KAKAO_LOGOUT_REDIRECT_URI
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: cannot import name 'KAKAO_API_KEY' from 'app.config' (/app/app/config.py)

config.py 들어가서, 필요한 값 추가해주고 저장.


실행이 잘 된다!

# python -m app.main
2025-02-26 09:16:16.629240: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2025-02-26 09:16:16.630298: I external/local_xla/xla/tsl/cuda/cudart_stub.cc:32] Could not find cuda drivers on your machine, GPU will not be used.
2025-02-26 09:16:16.635124: I external/local_xla/xla/tsl/cuda/cudart_stub.cc:32] Could not find cuda drivers on your machine, GPU will not be used.
2025-02-26 09:16:16.644449: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:477] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
E0000 00:00:1740561376.657289     363 cuda_dnn.cc:8310] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
E0000 00:00:1740561376.660996     363 cuda_blas.cc:1418] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2025-02-26 09:16:16.674242: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
/app/app/main.py:26: DeprecationWarning: 
        on_event is deprecated, use lifespan event handlers instead.

        Read more about it in the
        [FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).
        
  @app.on_event("startup")

'개발 Error' 카테고리의 다른 글

[MySQL] DB 수정하기  (0) 2025.02.25
[WSL] CUDA Version Downgrade  (0) 2025.02.24
[GitHub] LFS 삭제 후, failed error 발생  (0) 2025.02.22
[GitHub] LFS 삭제하기  (0) 2025.02.22
[Lenovo ThinkPad] Fn 키와 Ctrl 키 바꾸기  (0) 2025.02.22