donaldzou / WGDashboard

Simple dashboard for WireGuard VPN written in Python w/ Flask
https://donaldzou.github.io/WGDashboard-Documentation/
Apache License 2.0
1.47k stars 217 forks source link

3.0.6 will not start #278

Closed kwschnei closed 3 months ago

kwschnei commented 3 months ago

Describe The Problem After updating to version 3.0.6 with ./wgd.sh update, WGDashboard will no longer start. Attempting to do so produces the error below:

Please provide the error traceback here


| Starting WGDashboard with Gunicorn in the background.    |
Failed to read config file: /home/kwschnei/Wireguard-Dashboard/src/gunicorn.conf.py
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/app/base.py", line 111, in get_config_from_filename
    spec.loader.exec_module(mod)
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/kwschnei/Wireguard-Dashboard/src/gunicorn.conf.py", line 2, in <module>
    import dashboard
  File "/home/kwschnei/Wireguard-Dashboard/src/dashboard.py", line 25, in <module>
    from flask import Flask, request, render_template, redirect, url_for, session, jsonify, g
  File "/usr/local/lib/python3.10/dist-packages/flask/__init__.py", line 5, in <module>
    from .app import Flask as Flask
  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 30, in <module>
    from werkzeug.urls import url_quote
ImportError: cannot import name 'url_quote' from 'werkzeug.urls' (/usr/local/lib/python3.10/dist-packages/werkzeug/urls.py)
| Log files is under log/                                  |
------------------------------------------------------------

**To Reproduce**
sudo ./wgd.sh start

**OS Information:**
 - OS: Ubuntu 22.04.04 LTS (GNU/Linux 5.15.0-1055-raspi aarch64)
 - Python Version: 3.10.12
DaanSelen commented 3 months ago

Did you use any Python Virtual Environments? Are the permissions set correctly?

kwschnei commented 3 months ago

Honestly, things have been working for a couple years - this only happened after the update to 3.0.6.

I'm not familiar with Python Virtual Environments. (I did the initial setup straight from the guide and they weren't mentioned.) I'll do some research to figure out what those are and see if that's something on my system.

DaanSelen commented 3 months ago

I'm not familiar with Python Virtual Environments. (I did the initial setup straight from the guide and they weren't mentioned.) I'll do some research to figure out what those are and see if that's something on my system.

Maybe try to fetch the requirements again, there might have been some updates in the dependencies. I see specifically ImportError: cannot import name 'url_quote' from 'werkzeug.urls' (/usr/local/lib/python3.10/dist-packages/werkzeug/urls.py) this line which is important.

kwschnei commented 3 months ago

I tried fixing by re-running the installer, which would have the effect of fetching the requirements again, right? (As a note, I've got 2 Raspberry Pis with this setup, and the error is happening on both of them.)

DaanSelen commented 3 months ago

I do not know the current environment, you could for the ease of use create a Docker image and run those on Raspberry Pi's but if you would like it to stay on the hardware. Then perhaps you can re-run the pip3 install -r requirements.txt. Or can you provide some details on how to reproduce this issue?

kwschnei commented 3 months ago
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: Flask in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 1)) (2.2.2)
Requirement already satisfied: ifcfg in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 2)) (0.24)
Requirement already satisfied: psutil in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 3)) (5.9.8)
Requirement already satisfied: icmplib in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 4)) (3.0.4)
Requirement already satisfied: flask-qrcode in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 5)) (3.1.0)
Requirement already satisfied: gunicorn in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 6)) (22.0.0)
Requirement already satisfied: certbot in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 7)) (1.29.0)
Requirement already satisfied: Werkzeug>=2.2.2 in /usr/local/lib/python3.10/dist-packages (from Flask->-r requirements.txt (line 1)) (3.0.3)
Requirement already satisfied: Jinja2>=3.0 in /usr/local/lib/python3.10/dist-packages (from Flask->-r requirements.txt (line 1)) (3.1.4)
Requirement already satisfied: itsdangerous>=2.0 in /usr/local/lib/python3.10/dist-packages (from Flask->-r requirements.txt (line 1)) (2.2.0)
Requirement already satisfied: click>=8.0 in /usr/local/lib/python3.10/dist-packages (from Flask->-r requirements.txt (line 1)) (8.1.7)
Requirement already satisfied: qrcode in /usr/local/lib/python3.10/dist-packages (from flask-qrcode->-r requirements.txt (line 5)) (7.3.1)
Requirement already satisfied: pillow in /usr/lib/python3/dist-packages (from flask-qrcode->-r requirements.txt (line 5)) (9.0.1)
Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from gunicorn->-r requirements.txt (line 6)) (24.0)
Requirement already satisfied: acme>=1.29.0 in /usr/local/lib/python3.10/dist-packages (from certbot->-r requirements.txt (line 7)) (1.29.0)
Requirement already satisfied: ConfigArgParse>=0.9.3 in /usr/lib/python3/dist-packages (from certbot->-r requirements.txt (line 7)) (1.5.3)
Requirement already satisfied: configobj>=5.0.6 in /usr/lib/python3/dist-packages (from certbot->-r requirements.txt (line 7)) (5.0.6)
Requirement already satisfied: cryptography>=2.5.0 in /usr/lib/python3/dist-packages (from certbot->-r requirements.txt (line 7)) (3.4.8)
Requirement already satisfied: distro>=1.0.1 in /usr/lib/python3/dist-packages (from certbot->-r requirements.txt (line 7)) (1.7.0)
Requirement already satisfied: josepy>=1.13.0 in /usr/local/lib/python3.10/dist-packages (from certbot->-r requirements.txt (line 7)) (1.13.0)
Requirement already satisfied: parsedatetime>=2.4 in /usr/lib/python3/dist-packages (from certbot->-r requirements.txt (line 7)) (2.6)
Requirement already satisfied: pyrfc3339 in /usr/lib/python3/dist-packages (from certbot->-r requirements.txt (line 7)) (1.1)
Requirement already satisfied: pytz>=2019.3 in /usr/lib/python3/dist-packages (from certbot->-r requirements.txt (line 7)) (2022.1)
Requirement already satisfied: setuptools>=41.6.0 in /usr/lib/python3/dist-packages (from certbot->-r requirements.txt (line 7)) (59.6.0)
Requirement already satisfied: zope.component in /usr/lib/python3/dist-packages (from certbot->-r requirements.txt (line 7)) (4.3.0)
Requirement already satisfied: zope.interface in /usr/lib/python3/dist-packages (from certbot->-r requirements.txt (line 7)) (5.4.0)
Requirement already satisfied: PyOpenSSL>=17.5.0 in /usr/lib/python3/dist-packages (from acme>=1.29.0->certbot->-r requirements.txt (line 7)) (21.0.0)
Requirement already satisfied: requests>=2.20.0 in /usr/lib/python3/dist-packages (from acme>=1.29.0->certbot->-r requirements.txt (line 7)) (2.25.1)
Requirement already satisfied: requests-toolbelt>=0.3.0 in /usr/lib/python3/dist-packages (from acme>=1.29.0->certbot->-r requirements.txt (line 7)) (0.9.1)
Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from Jinja2>=3.0->Flask->-r requirements.txt (line 1)) (2.1.1)

Apparently all the requirements are met.

I did look at transitioning to the docker image in v4, but there aren't actually install directions in the Readme for setting things up with Docker. I did the most obvious things:

git clone -b v4 https://github.com/donaldzou/WGDashboard.git wgdashboard
cd wgdashboard
sudo docker-compose up

However, it fails to start.

Building wheels for collected packages: psutil
  Building wheel for psutil (PEP 517): started
  Building wheel for psutil (PEP 517): finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 /tmp/tmp5oey3gg9 build_wheel /tmp/tmpo7xriv4t
       cwd: /tmp/pip-install-uf5us4rf/psutil
  Complete output (46 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-aarch64-cpython-38
  creating build/lib.linux-aarch64-cpython-38/psutil
  copying psutil/_psaix.py -> build/lib.linux-aarch64-cpython-38/psutil
  copying psutil/_common.py -> build/lib.linux-aarch64-cpython-38/psutil
  copying psutil/_psbsd.py -> build/lib.linux-aarch64-cpython-38/psutil
  copying psutil/_pssunos.py -> build/lib.linux-aarch64-cpython-38/psutil
  copying psutil/_psposix.py -> build/lib.linux-aarch64-cpython-38/psutil
  copying psutil/__init__.py -> build/lib.linux-aarch64-cpython-38/psutil
  copying psutil/_psosx.py -> build/lib.linux-aarch64-cpython-38/psutil
  copying psutil/_pslinux.py -> build/lib.linux-aarch64-cpython-38/psutil
  copying psutil/_pswindows.py -> build/lib.linux-aarch64-cpython-38/psutil
  copying psutil/_compat.py -> build/lib.linux-aarch64-cpython-38/psutil
  creating build/lib.linux-aarch64-cpython-38/psutil/tests
  copying psutil/tests/test_testutils.py -> build/lib.linux-aarch64-cpython-38/psutil/tests
  copying psutil/tests/test_linux.py -> build/lib.linux-aarch64-cpython-38/psutil/tests
  copying psutil/tests/test_windows.py -> build/lib.linux-aarch64-cpython-38/psutil/tests
  copying psutil/tests/test_aix.py -> build/lib.linux-aarch64-cpython-38/psutil/tests
  copying psutil/tests/test_bsd.py -> build/lib.linux-aarch64-cpython-38/psutil/tests
  copying psutil/tests/test_misc.py -> build/lib.linux-aarch64-cpython-38/psutil/tests
  copying psutil/tests/test_osx.py -> build/lib.linux-aarch64-cpython-38/psutil/tests
  copying psutil/tests/test_posix.py -> build/lib.linux-aarch64-cpython-38/psutil/tests
  copying psutil/tests/__main__.py -> build/lib.linux-aarch64-cpython-38/psutil/tests
  copying psutil/tests/test_system.py -> build/lib.linux-aarch64-cpython-38/psutil/tests
  copying psutil/tests/runner.py -> build/lib.linux-aarch64-cpython-38/psutil/tests
  copying psutil/tests/test_process_all.py -> build/lib.linux-aarch64-cpython-38/psutil/tests
  copying psutil/tests/__init__.py -> build/lib.linux-aarch64-cpython-38/psutil/tests
  copying psutil/tests/test_unicode.py -> build/lib.linux-aarch64-cpython-38/psutil/tests
  copying psutil/tests/test_process.py -> build/lib.linux-aarch64-cpython-38/psutil/tests
  copying psutil/tests/test_connections.py -> build/lib.linux-aarch64-cpython-38/psutil/tests
  copying psutil/tests/test_memleaks.py -> build/lib.linux-aarch64-cpython-38/psutil/tests
  copying psutil/tests/test_sunos.py -> build/lib.linux-aarch64-cpython-38/psutil/tests
  copying psutil/tests/test_contracts.py -> build/lib.linux-aarch64-cpython-38/psutil/tests
  running build_ext
  building 'psutil._psutil_linux' extension
  creating build/temp.linux-aarch64-cpython-38
  creating build/temp.linux-aarch64-cpython-38/psutil
  creating build/temp.linux-aarch64-cpython-38/psutil/arch
  creating build/temp.linux-aarch64-cpython-38/psutil/arch/linux
  aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_SIZEOF_PID_T=4 -DPSUTIL_VERSION=598 -DPy_LIMITED_API=0x03060000 -DPSUTIL_ETHTOOL_MISSING_TYPES=1 -DPSUTIL_LINUX=1 -I/usr/include/python3.8 -c psutil/_psutil_common.c -o build/temp.linux-aarch64-cpython-38/psutil/_psutil_common.o
  psutil could not be installed from sources because gcc is not installed. Try running:
    sudo apt-get install gcc python3-dev
  error: command 'aarch64-linux-gnu-gcc' failed: No such file or directory
  ----------------------------------------
  ERROR: Failed building wheel for psutil
Failed to build psutil
ERROR: Could not build wheels for psutil which use PEP 517 and cannot be installed directly
The command '/bin/sh -c pip3 install -r /opt/wgdashboard_tmp/requirements.txt   --no-cache-dir' returned a non-zero code: 1
ERROR: Service 'wgdashboard' failed to build : Build failed
DaanSelen commented 3 months ago

I did look at transitioning to the docker image in v4, but there aren't actually install directions in the Readme for setting things up with Docker. I did the most obvious things:

Sorry to advertise my own thing, but for the current version I created a Pull Request for version 3.0.6.2 which I am trying to get into the repository. With detailed install instructions: https://github.com/DaanSelen/WGDashboard-dockerized/blob/main/docker/Docker-explain.md

To resolve the initial issue, can you also try to run the wgd.sh with debug passed into it? So that would make it ./wgd.sh debug this should give good detailed explanation.

kwschnei commented 3 months ago

If I can't get it resolved through the main repository, I'll check your's out.

Unfortunately, the debug mode provides no new information.

------------------------------------------------------------
| Starting WGDashboard in the foreground.                  |
Traceback (most recent call last):
  File "/home/kwschnei/Wireguard-Dashboard/src/dashboard.py", line 25, in <module>
    from flask import Flask, request, render_template, redirect, url_for, session, jsonify, g
  File "/usr/local/lib/python3.10/dist-packages/flask/__init__.py", line 5, in <module>
    from .app import Flask as Flask
  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 30, in <module>
    from werkzeug.urls import url_quote
ImportError: cannot import name 'url_quote' from 'werkzeug.urls' (/usr/local/lib/python3.10/dist-packages/werkzeug/urls.py)
------------------------------------------------------------
DaanSelen commented 3 months ago

Unfortunately, the debug mode provides no new information.

Might have a lead on how to fix this: https://stackoverflow.com/questions/77213053/why-did-flask-start-failing-with-importerror-cannot-import-name-url-quote-fr

To make it easier: "I had the same problem. It is because Werkzeug 3.0.0 was released and Flask doesn't specify the dependency correctly (requirements says Werkzeug>=2.2.0). This is why, Werkzeug 3.0.0 is still installed and Flask 2.2.2 isn't made for Werkzeug 3.0.0.

Solution: Just set a fix version for Werkzeug such as Werkzeug==2.2.2 in your requirements.txt and it should work."

You can try if this fixes the issue.

kwschnei commented 3 months ago

I ran across that same post earlier in the day, along with one that suggested setting a specific version of Flask as well, but that didn't get me anywhere - because I didn't run the install script afterwards. I don't feel great about pinning deprecated software, but it probably won't kill me to do so until v4 is officially released.

For anyone coming here after me, set requirements.txt as follows:

Flask
ifcfg
psutil
icmplib
flask-qrcode
gunicorn
certbot
Werkzeug==2.2.2

Then:

sudo ./wgd.sh install
sudo ./wgd.sh start

Thanks for all your help @DaanSelen

donaldzou commented 3 months ago

I ran across that same post earlier in the day, along with one that suggested setting a specific version of Flask as well, but that didn't get me anywhere - because I didn't run the install script afterwards. I don't feel great about pinning deprecated software, but it probably won't kill me to do so until v4 is officially released.

For anyone coming here after me, set requirements.txt as follows:


Flask

ifcfg

psutil

icmplib

flask-qrcode

gunicorn

certbot

Werkzeug==2.2.2

Then:


sudo ./wgd.sh install

sudo ./wgd.sh start

Thanks for all your help @DaanSelen

Hi @kwschnei, I'm sorry that you're encountering this issue. Do you mind telling me which OS you're using and I'll do some testing with a VM and make the correct adjustments.

I'll reopen this issue until I know what's going on😊

Best, Donald

DaanSelen commented 3 months ago

I ran across that same post earlier in the day, along with one that suggested setting a specific version of Flask as well, but that didn't get me anywhere - because I didn't run the install script afterwards. I don't feel great about pinning deprecated software, but it probably won't kill me to do so until v4 is officially released. For anyone coming here after me, set requirements.txt as follows:


Flask

ifcfg

psutil

icmplib

flask-qrcode

gunicorn

certbot

Werkzeug==2.2.2

Then:


sudo ./wgd.sh install

sudo ./wgd.sh start

Thanks for all your help @DaanSelen

Hi @kwschnei, I'm sorry that you're encountering this issue. Do you mind telling me which OS you're using and I'll do some testing with a VM and make the correct adjustments.

I'll reopen this issue until I know what's going on😊

Best, Donald

I suspect that one of the dependencies has been updated, and deprecated one of the functions used in WGDashboard. That is why I submitted a issue of feature request https://github.com/donaldzou/WGDashboard/issues/279

kwschnei commented 3 months ago

@donaldzou I'm running Ubuntu 22.04.04 LTS (GNU/Linux 5.15.0-1055-raspi aarch64) on a Raspberry Pi 4. (With all of the latest updates applied.)

donaldzou commented 3 months ago

Ahh I see what is going on.. I will add the version number in the requirements.txt when I release v4 :)