hsand / pia-wg

A WireGuard configuration utility for Private Internet Access
GNU General Public License v3.0
303 stars 51 forks source link

Generate-config.py fails with FileNotFoundError #11

Open m3ph1 opened 2 years ago

m3ph1 commented 2 years ago

I grabbed pia-wg today and installed python 3.10.2 and follow ed the readme.

Generate-config.py fails with "FileNotFoundError: [WinError 2] The system cannot find the file specified" and i have no idea why.

Here's my whole console output:

(venv2) D:\pia-wg-master\pia-wg-master>generate-config.py Traceback (most recent call last): File "D:\pia-wg-master\pia-wg-master\generate-config.py", line 9, in pia.generate_keys() File "D:\pia-wg-master\pia-wg-master\piawg.py", line 54, in generate_keys self.privatekey = subprocess.run(['wg', 'genkey'], stdout=subprocess.PIPE, encoding="utf-8").stdout.strip() File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 501, in run with Popen(*popenargs, **kwargs) as process: File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 966, in init self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1435, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file specified

RoggerTan commented 2 years ago

Did you forget to install Wireguard? It seems like the "wg genkey" command couldn't be executed.

ptooey commented 2 years ago

FYI I dealt with the same issue, where wg wouldn't execute from CLI (PowerShell/cmd).

Looks to me like the WireGuard install path is appended to the System PATH environment variable, and only works if you run CLI in Administrator mode.

The more obvious indicator of failure is when a Console window pops up blank and closes after the final step generate-config.py is executed.

When run in Administrator mode, the Console window actually prompts you to select which VPN Server location you want to generate settings for and successfully generates a file after closing, instead of appearing blank then closing.

d-rez commented 2 years ago

Looks like WireGuard installer didn't add itself to PATH, so the solution to this is to run the following right before executing generate-config.py:

set PATH=%PATH%;C:\Program Files\WireGuard

(Assuming you installed WireGuard to the above path). It will execute fine then.