Python not interpreting changed files, using obsol

2019-02-19 11:42发布

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 the previously pre-compiled .pyc even if the .py source was changed.

Error messages actually quotes the correct line from the most current source. Except if the position of the line changed, then it quotes the line which is in the place where the error occurred previously.

Deleting .pyc files causes them to be recreated from the current version. Deleting all .pycs is a poor workaround for now.

How can I get to the root cause of the problem?

3条回答
贪生不怕死
2楼-- · 2019-02-19 11:59

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.

查看更多
叼着烟拽天下
3楼-- · 2019-02-19 12:02

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
查看更多
手持菜刀,她持情操
4楼-- · 2019-02-19 12:06

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.

查看更多
登录 后发表回答