Python not interpreting changed files, using obsolete .pyc

后端 未结 3 747
遇见更好的自我
遇见更好的自我 2021-01-15 07:55

Using the Google App Engine to develop in python yesterday it stopped running the current version of the script. Instead of executing the most recent version it seems to run

相关标签:
3条回答
  • 2021-01-15 08:35

    Did you check your system clock? I believe python determine whether to use the .pyc or .py based on timestamps. If your system clock got pushed back, then it would see the .pyc files as newer until the system clock caught up to the last time they were built.

    0 讨论(0)
  • 2021-01-15 08:52

    The following steps solved the issue temporarily:

    1. Delete GoogleAppEngineLauncher from your Applications folder.
    2. Rename the file ~/Library/Application Support/GoogleAppEngineLauncher/Projects.plist (e.g. Project.plist.backup
    3. Rename the file ~/Library/Preferences/com.google.GoogleAppEngineLauncher.plist (e.g. com.google.GoogleAppEngineLauncher.plist.backup)
    4. Download and install Google App Engine Launcher again.
    5. Use "File", "Add existing application…" to add your projects again, do not forget to set any flags you had set before.

    Alternatively it might even work starting GAEL once, closing it and putting your backed up preference files back into place as to avoid having to reconfigure.

    Edit: Turns out that fixes it… temporarily. Not exactly a very easy issue to debug. Weirdly enough it works when running the appserver from the command line, such as

    dev_appserver.py testproject/ -p 8082 --debug
    
    0 讨论(0)
  • 2021-01-15 08:58

    Are you editing the .py files on a different system than where they are being compiled ?

    The compiler recompiles the .py files if its modification date is newer than the modification date of the .pyc file.

    The fact that it is picking the .pyc file for use points to the fact that your .py file has an older modification date. This is only possible if your .py file is being modified on a different system and then being copied to the one where it is to be used and the editing environment/system's clock is set behind the runtime enviroment/system's clock.

    0 讨论(0)
提交回复
热议问题