1

I have created a pyramid application using pcreate, now when I try to run it using pserve with --reload, I get following error

 SyntaxError: Non-ASCII character '\x90' in file <path>\pserve.exe on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

Interestingly this error shows up only when I use --reload, if I remove reload it starts fine.

After debugging, I see another file pserve-script.py at the same location of pserve.exe and this python script is internally called by pserve.exe ( I don't understand why? when pserve itself is executable)

The above pserve-script.py has following content and I assume the above error is because of following shebang.

#!c:\<folder-path>\Scripts\python.exe
# EASY-INSTALL-ENTRY-SCRIPT: 'pyramid','console_scripts','pserve'
__requires__ = 'pyramid'
import re
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(
        load_entry_point('pyramid', 'console_scripts', 'pserve')()
    )
DevC
  • 7,055
  • 9
  • 39
  • 58
  • Does contain characters which are not ascii? – zvone Sep 24 '16 at 12:42
  • @zvone no all good, it works if I just remove --reload and I don't understand why it calls pserve-script.py while it can directly call pserve.exe which exists in same path – DevC Sep 24 '16 at 12:48
  • I have no idea what pserve does, but it does not look like the problem is in pserve-script.py. The error says there is a non-ascii character and there is no such character here. Furthermore, the error say pserve.exe and not pserve-script.py – zvone Sep 24 '16 at 14:02
  • @DevC Can you please expand the script to contain full `` because it's complaining about ``. `--reload` is related to how processes are created (on reload) and I think it might different code path when executing the processes in this case, causing the issue to surface. – Mikko Ohtamaa Sep 24 '16 at 14:05

1 Answers1

1

This is an issue with the way the pserve reloader is written in Pyramid versions less than 1.8, as far as I know, we (Pyramid developers) haven't figured out a reason why this happens.

In Pyramid 1.8 (which just had an alpha version released) we moved to using hupper which should work much better under Windows.

Please install it using:

pip install pyramid==1.8a1

And see if the issue disappears!

X-Istence
  • 16,324
  • 6
  • 57
  • 74