Apache2 SNMP Extend not working in Python3

hi!

looks like apache snmp extend not work under latest Python 3, already installed latest python-urlgrabber python-pycurl

root@host:/etc/snmp# python -V
Python 3.6.9

root@host:/etc/snmp# apt install python3-pycurl
Reading package lists… Done
Building dependency tree
Reading state information… Done
Suggested packages:
libcurl4-gnutls-dev python-pycurl-doc python3-pycurl-dbg
The following NEW packages will be installed:
python3-pycurl
0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
Need to get 42.5 kB of archives.
After this operation, 173 kB of additional disk space will be used.
Get:1 Index of /ubuntu bionic/main amd64 python3-pycurl amd64 7.43.0.1-0.2 [42.5 kB]
Fetched 42.5 kB in 1s (61.9 kB/s)
Selecting previously unselected package python3-pycurl.
(Reading database … 156919 files and directories currently installed.)
Preparing to unpack …/python3-pycurl_7.43.0.1-0.2_amd64.deb …
Unpacking python3-pycurl (7.43.0.1-0.2) …
Setting up python3-pycurl (7.43.0.1-0.2) …

root@host:/etc/snmp# pip3 install urlgrabber
Collecting urlgrabber
Using cached https://files.pythonhosted.org/packages/b1/23/61cb4d829138f24bfae2c77af6794ddd67240811dbb4e3e2eb22c4f57742/urlgrabber-4.1.0.tar.gz
Requirement already satisfied: pycurl in /usr/lib/python3/dist-packages (from urlgrabber)
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from urlgrabber)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from urlgrabber)
Building wheels for collected packages: urlgrabber
Running setup.py bdist_wheel for urlgrabber … done
Stored in directory: /root/.cache/pip/wheels/29/75/59/b9931291ccc84f84004311686ca4961ba03ae7470e09e509f0
Successfully built urlgrabber
Installing collected packages: urlgrabber
Successfully installed urlgrabber-4.1.0

root@host:/etc/snmp# python3 apache-stats.py
File “apache-stats.py”, line 40
f = open ( CACHEFILE+‘.TMP.’+os.getpid(), ‘w’ )
^
SyntaxError: invalid syntax

but running fine in python2:

root@host:/etc/snmp# python2 apache-stats.py
1693699
50297873408
.162749
335326
5.0509
149997
29697.1
29
6
6
0
5
11
7
0
6
0
0
0

please advice.

script is python2 as you say. Feel free to contribute an updated script. There may even be one pending.

hi, found some walk around:

1. make sure that python 2.7 is installed
2. running this on server:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
sudo update-alternatives --set python /usr/bin/python2.7

3.check default python, should be python 2.7
root@host:/etc/snmp# python -V
Python 2.7.17