Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error email-oauth2-proxy on linux (and windows) :( #45

Closed
DFO-WAT opened this issue Aug 10, 2022 · 8 comments
Closed

error email-oauth2-proxy on linux (and windows) :( #45

DFO-WAT opened this issue Aug 10, 2022 · 8 comments

Comments

@DFO-WAT
Copy link

DFO-WAT commented Aug 10, 2022

hello

------------DEBIAN 11 INSTALL ----------------

already to start congratulations for this project :)
I wanted to try it on Debian 11 with Python3.0 and after having several problems and several searches I managed to finally make it almost work :(
At first I had a problem with pystray but I found the package then I saw that my DISPLAY variable was empty (it's a VM) so I put :1 but only it doesn't work it stays stuck on:

No protocol specified
unable to init server : could not connect : connection refused
No protocol specified
unable to init server : could not connect : connection refused
No protocol specified
unable to init server : could not connect : connection refused
No protocol specified
unable to init server : could not connect : connection refused

root@ProxyOAuth:/opt/oauth2-proxy# pip list
Package Version


attrs 20.3.0
Brlapi 0.8.2
cached-property 1.5.2
certifi 2020.6.20
cffi 1.15.1
chardet 4.0.0
chrome-gnome-shell 0.0.0
configobj 5.0.6
cryptography 37.0.4
cupshelpers 1.0
dbus-python 1.2.16
distro 1.5.0
distro-info 1.0
docker 4.1.0
docker-compose 1.25.0
dockerpty 0.4.1
docopt 0.6.2
httplib2 0.18.1
idna 2.10
importlib-metadata 1.6.0
jsonschema 3.2.0
louis 3.16.0
Mako 1.1.3
MarkupSafe 1.1.1
more-itertools 4.2.0
Pillow 9.2.0
pip 20.3.4
proxy-tools 0.1.0
pycairo 1.16.2
pycparser 2.21
pycups 2.0.1
pycurl 7.43.0.6
PyGObject 3.38.0
pyrsistent 0.15.5
PySimpleSOAP 1.16.2
pysmbc 1.0.23
pystray 0.19.4
python-apt 2.2.1
python-debian 0.1.39
python-debianbts 3.1.0
python-xlib 0.31
pywebview 3.6.3
pyxdg 0.27
PyYAML 5.3.1
reportbug 7.10.3+deb11u1
requests 2.25.1
setuptools 52.0.0
six 1.16.0
texttable 1.6.3
timeago 1.0.15
unattended-upgrades 0.1
urllib3 1.26.5
websocket-client 0.57.0
wheel 0.34.2
xdg 5
zipp 1.0.0

----------------------------- WINDOWS INSTALL ---------------------------------

so I said to myself good we will try on a Windows Server 2022 so I installed Python and the dependencies (or almost) but there I have a problem with webview (or pywebview) impossible to install it and before that I got the error with Pythonnet (but I think it's related) despite installing Visual C++14 I can't get it to work

:\temp\oauth2>python emailproxy.py
C:\temp\oauth2\emailproxy.py:10: DeprecationWarning: The asyncore module is deprecated and will be removed in Python 3.12. The recommended replacement is asyncio
import asyncore
Traceback (most recent call last):
File "C:\temp\oauth2\emailproxy.py", line 43, in
import webview
ModuleNotFoundError: No module named 'webview'

I am desperate :(

C:\temp\oauth2>pip install webview
Collecting webview
Using cached webview-0.1.5.tar.gz (18 kB)
Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for webview, since package 'wheel' is not installed.
Installing collected packages: webview
Running setup.py install for webview ... error
error: subprocess-exited-with-error

× Running setup.py install for webview did not run successfully.
│ exit code: 1
╰─> [21 lines of output]
running install
C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standard-based tools.
warnings.warn(
running build
running build_ext
building 'webview' extension
creating build
creating build\temp.win-amd64-cpython-310
creating build\temp.win-amd64-cpython-310\Release
creating build\temp.win-amd64-cpython-310\Release\webview
"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.33.31629\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DWEBVIEW_WINAPI=1 -IC:\Users\username\AppData\Local\Programs\Python\Python310\include -IC:\Users\username\AppData\Local\Programs\Python\Python310\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.33.31629\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\ 14.33.31629\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10 \include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um" "-IC:\Program Files (x86)\Windows Kits\10 \include\10.0.19041.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" "-IC:\Program Files (x86)\Windows Kits \10\include\10.0.19041.0\cppwinrt" /Tcwebview/webview.c /Fobuild\t emp.win-amd64-cpython-310\Release\webview/webview.obj
webview.c
C:\Users\username\AppData\Local\Temp\pip-install-phaodxqi\webview_9b5bb0675bff4cfaab62ee83f25ae460\webview\webview.h(1085): warning C4477: 'sscanf'ÿ: format string '%02x' requires a argument of type 'unsigned int *', but variadic argument 1 is of type 'char *'
C:\Users\username\AppData\Local\Temp\pip-install-phaodxqi\webview_9b5bb0675bff4cfaab62ee83f25ae460\webview\webview.h(1085): note: use '%hhx' in the format string
C:\Users\username\AppData\Local\Temp\pip-install-phaodxqi\webview_9b5bb0675bff4cfaab62ee83f25ae460\webview\webview.h(1338): warning C4267: 'initialization'ÿ: converting 'size_t' to 'int', possible loss data
webview/webview.c(117): error C2065: 'PATH_MAX': undeclared identifier
webview/webview.c(117): error C2057: constant expression expected
webview/webview.c(117): error C2466: unable to allocate an array of constant size 0
webview/webview.c(117): error C2133: 'result'ÿ: unknown size
webview/webview.c(123): warning C4034: sizeof returns 0
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.33.31629\bin\HostX86\x64\cl .exe' failed with exit code 2
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> webview

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

I have test with the .WHL files (for Pythonnet)

pip install pythonnet-2.5.2-cp39-cp39-win.whl
ERROR: pythonnet-2.5.2-cp39-cp39-win.whl is not a supported wheel on this platform.

C:\temp\oauth2>pip list
Package Version


Pillow 9.2.0
pip 22.2.2
proxy-tools 0.1.0
pycparser 2.21
pystray 0.19.4
setuptools 63.2.0
six 1.16.0
timeago 1.0.15
cryptography

by removing the import webview it launches correctly and works well but suddenly how to do without the webview? can an external browser be used?

If you can or you can help me.. thank you in advance

@simonrob
Copy link
Owner

I can't check the Debian setup right now, but things should work okay on Windows. The pythonnet package is discussed in the readme - have you tried a prebuilt wheel?

The webview issue is linked to pythonnet, but confusingly the actual package you need is pywebview, not webview. The requirements.txt file should handle this for you. Regardless, if you cannot get things working via this route, you could try the --no-gui and --local-server-auth options. See the proxy's readme for more details here.

@DFO-WAT
Copy link
Author

DFO-WAT commented Aug 11, 2022

ok no big deal for Debian.
Ok it's pywebview but on Windows I tried the readme packages for pythonnet but unfortunately I got this error

C:\temp\oauth2>pip install pythonnet-2.5.2-cp39-cp39-amd64.whl
ERROR: pythonnet-2.5.2-cp39-cp39-amd64.whl is not a supported wheel on this platform.

C:\temp\oauth2>pip install pythonnet-2.5.2-cp39-cp39-win32.whl
ERROR: pythonnet-2.5.2-cp39-cp39-win32.whl is not a supported wheel on this platform.

I am in Python 3.10.6

@DFO-WAT
Copy link
Author

DFO-WAT commented Aug 11, 2022

If I run with no-gui and no external auth I have the same problem

C:\temp\oauth2>python --no-gui --local-server-auth emailproxy.py
unknown option --no-gui
usage: python [option] ... [-c cmd | -m mod | queue | -] [arg] ...
Try `python -h' for more information.

C:\temp\oauth2>python emailproxy.py --no-gui --local-server-auth
C:\temp\oauth2\emailproxy.py:10: DeprecationWarning: The asyncore module is deprecated and will be removed in Python 3.12. The recommended replacement is asyncio
import asyncore
Traceback (most recent call last):
File "C:\temp\oauth2\emailproxy.py", line 43, in
import webview
ModuleNotFoundError: No module named 'webview'

only if I remove import webview in the emailproxy.py then it launches but it will work correctly?
anyway it looks like :)

Thank you very much for your answers and congratulations

@DFO-WAT
Copy link
Author

DFO-WAT commented Aug 11, 2022

When I use pip install -r requirements.txt

Requirement already satisfied: pycparser in c:\users\user\appdata\local\programs\python\python310\lib\site-packages (from cffi>=1.12->cryptography->-r requirements.txt (line 2)) ( 2.21)
Using legacy 'setup.py install' for configobj, since package 'wheel' is not installed.
Using legacy 'setup.py install' for pythonnet, since package 'wheel' is not installed.
Installing collected packages: pythonnet, configobj, pywebview
Running setup.py install for pythonnet ... error
error: subprocess-exited-with-error

× Running setup.py install for pythonnet did not run successfully.
│ exit code: 1
╰─> [6 lines of output]
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help

  error: option --single-version-externally-managed not recognized
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> pythonnet

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

@simonrob
Copy link
Owner

Removing the webview import will have no impact on the no gui and local server auth options. You will need to monitor the proxy's log output in this mode, however, as it has no other way to notify about authentication requests.

@simonrob
Copy link
Owner

I'm assuming that this has now been resolved, but ee0bec3 updates requirements.txt to force a compatible version of pythonnet when using Python 3.10+ on Windows. You can also do this manually if needed (before installing the proxy's requirements): pip install --pre pythonnet

@DFO-WAT
Copy link
Author

DFO-WAT commented Aug 16, 2022

Great ! indeed with pip install --pre pythonnet it works then the requierements.txt
Thanks a lot :)

It launches correctly but when I click to open the window I get an error

(interactive mode)
[pywebview] EdgeHTML is deprecated. See https://pywebview.flowrl.com/guide/renderer.html#web-engine on details how to use Edge Chromium

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.Forms.Control.get_CacheTextInternal()
at System.Windows.Forms.Control.get_Text()
at System.Windows.Forms.Control.set_Text(String value)
--- End of stack trace from previous location at which exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Python.Runtime.PythonException.ThrowLastAsClrException()
at Python.Runtime.Dispatcher.TrueDispatch(Object[] args)
at Python.Runtime.Dispatcher.Dispatch(Object[] args)
at __System_Threading_ThreadStartDispatcher.Invoke()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

--------------> UPDATE ----------------- ->

I installed Webview2 runtimes but it still didn't work! I looked a bit at the problems other people had and saw someone talking about the same problem.
I downgraded the Pythonnet
pip install pythonnet==3.0.0a2

and now it's good :)

@simonrob
Copy link
Owner

Great - I'm glad this was resolved.

Re: needing to specify pythonnet 3.0.0a2, this will be resolved once a new pywebview is released to include this fix (and the need to specify a prelease will be removed entirely once pythonnet 3 is released).

simonrob added a commit that referenced this issue Aug 17, 2022
Also add missing setuptools dependency (for pkg_resources)
simonrob added a commit that referenced this issue Aug 24, 2022
Simplifies installation in headless / no-GUI environments (see, e.g., #1, #2, #11, #41, #45, 48, #49, #54, #55)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants