OpenVPN / openvpn3-linux

OpenVPN 3 Linux client
GNU Affero General Public License v3.0
563 stars 151 forks source link

openvpn2 front-end: ModuleNotFoundError #6

Closed 481wgxoy4 closed 3 years ago

481wgxoy4 commented 5 years ago

Hey there,

I just want to inform you about one minor bug I noticed on Debian 9 and Ubuntu 18.04: After compiling and installing the project, using /usr/bin/openvpn2 produces the following error:

/usr/bin/openvpn2 --help

Traceback (most recent call last): File "/usr/bin/openvpn2", line 45, in from openvpn3 import StatusMajor, StatusMinor ModuleNotFoundError: No module named 'openvpn3'

Using openvpn3-linux/src/python/openvpn2 on the other hand works as expected. openvpn3-linux/src/python/openvpn2 --help (produces expected output)

dsommers commented 5 years ago

Hi,

Yes, this is a known issue when installing from source directly (tarball or git), on at least Debian and Ubuntu. The "problem" is the automatically generated install rules autoconf/automake figures out ends up using /usr/lib/python3.?/site-packages/, which is where the openvpn3 module lands. But on Debian and Ubunty, Python base installs has been modified to use /usr/lib/python3.?/ or /usr/lib/python3.?/dist-packages/ instead - and autoconf/automake doesn't detect this. I haven't checked that many Linux distributions, but RHEL/CentOS and Fedora uses the site-packages directory - which autoconf/automake expects.

Quick fix:

# ln -sf /usr/lib/python3.?/site-packages/openvpn3 /usr/lib/python3.?/openvpn3

If someone is capable of figuring out the proper Python 3 install directory with autoconf/automake automatically so it works out-of-the-box across all distributions, I will happily review such patches.

As for a quick comparison:

On RHEL-7

 $ python3 -m site
 sys.path = [
     '/home/user',
     '/usr/lib64/python36.zip',
     '/usr/lib64/python3.6',
     '/usr/lib64/python3.6/lib-dynload',
     '/home/user/.local/lib/python3.6/site-packages',
     '/usr/lib64/python3.6/site-packages',
     '/usr/lib/python3.6/site-packages',
 ]

On Ubuntu 18.04 LTS

 $ python3 -m site
 sys.path = [
     '/home/user',
     '/usr/lib/python36.zip',
     '/usr/lib/python3.6',
     '/usr/lib/python3.6/lib-dynload',
     '/usr/local/lib/python3.6/dist-packages',
     '/usr/lib/python3/dist-packages',
 ]
dsommers commented 3 years ago

Since the Debian packages somehow manages to do this correct, we will not try to hack around this any further. Using dist-packages is a Debianism which we don't want to add additional hacks around just for that distro. And especially not when the Debian packaging tools seems to package the Python files correctly.