Error running y4web with nssm

99 views
Skip to first unread message

Paolo Berto

unread,
Jan 9, 2022, 9:47:45 AM1/9/22
to py4web
Hello all,

I am trying to run py4web as a service on windows using nssm, but at startup on stderror the program gives the following errors:

Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python310\Scripts\py4web.exe\__main__.py", line 7, in <module>
  File "C:\Program Files\Python310\lib\site-packages\click\core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "C:\Program Files\Python310\lib\site-packages\click\core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "C:\Program Files\Python310\lib\site-packages\click\core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Program Files\Python310\lib\site-packages\click\core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Program Files\Python310\lib\site-packages\click\core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "C:\Program Files\Python310\lib\site-packages\py4web\core.py", line 1919, in run
    click.secho(ART, fg="blue")
  File "C:\Program Files\Python310\lib\site-packages\click\termui.py", line 659, in secho
    return echo(message, file=file, nl=nl, err=err, color=color)
  File "C:\Program Files\Python310\lib\site-packages\click\utils.py", line 298, in echo
    file.write(out)  # type: ignore
  File "C:\Program Files\Python310\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 2-8: character maps to <undefined>

When the service is active py4web does not work and no page is reachable.

Does anyone have any helpful suggestions on how to fix this problem?

Regards

Paolo

Nico Zanferrari

unread,
Jan 10, 2022, 5:22:53 PM1/10/22
to Paolo Berto, py4web
Hi,

I've tried the pythoncom instructions, but I have the same problem, too!

Anyhow, don't ask me why this happens, but I've found a simple workaround at the problem. Use NSSM and configure the service to run a CMD like this:

start "py4web" "C:\Program Files\Python310\Scripts\py4web.exe" run apps
pause

Note that both the START and the PAUSE command are needed. I think that Windows 10 kill all the process unless the starting CMD is kept alive with the PAUSE.... 


Nico

Il giorno dom 9 gen 2022 alle ore 23:23 Nico Zanferrari <nico...@gmail.com> ha scritto:
Hi Paolo,

it seems you're using Windows and python 3.10 (installed for all users in C:\Program Files\Python310. Also, you've pip-installed py4web.

I've tried with python 3.10.1 and the latest nssm binary with a CMD as the starting program. Unfortunately I've exactly the same problem and I'm not able to resolve it ;-(
I've also tried by configuring the service to run py4web.exe and even python.exe but nothing changes.

Maybe using nssm was not a good idea... Has anyone tried the pythoncom libraries (https://stackoverflow.com/a/32440/14104572) ?

nico






--
You received this message because you are subscribed to the Google Groups "py4web" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py4web+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/4ba6c4bf-89ed-49b1-88d9-6d4ea0e6b201n%40googlegroups.com.

Paolo Berto

unread,
Jan 11, 2022, 4:24:45 PM1/11/22
to py4web
I also tried FireDaemon Pro, but the result is the same.
Same output on stderr.


Paolo

Paolo Berto

unread,
Jan 11, 2022, 4:41:21 PM1/11/22
to py4web
Great Nico, as a batch file on windows 11 it works, tomorrow I will try it on windows server too.

It would be anyway a good thing if the windows installation includes also a version for use as a service without using nssm or similar.

Paolo
Reply all
Reply to author
Forward
0 new messages