79472090

Date: 2025-02-27 09:00:23
Score: 1
Natty:
Report link

I've recently made a shell script to run this project separately, and I've ran into a similar issue: when running in debug mode, the same error occurs on "Restarting with stat" specifically, the initial run is fine. This made me think it's an issue with Flask or Python, not with PyCharm.

After trying out answers from this StackOverflow thread to run the app by providing the full path instead of a relative one, I noticed the error now happened when opening some file in the beginning of the setup.

I reworded my question slightly and came upon this GitHub discussion, in which a Flask maintainer says Flask silently changing working directories if it happens to open a file when starting is intended behavior. Complete lunacy, but what do I know.

Solution

Use FLASK_SKIP_DOTENV=1 and load all env variables either via

set -o allexport
source path/to/extra/.env
set +o allexport

if using a shell script like I did or manual load_dotenv() calls inside your app (or both).

Reasons:
  • Blacklisted phrase (1): StackOverflow
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: bqback