essandess/easylist-pac-privoxy

Error compiling easylist_pac.py under osx with python 3.6

regsgood opened this issue · 8 comments

Hi,
great programm- just what I was looking for ;-)
As I'm a totally newbi to python I just managed to install under osx (El Captain).
When I run your script I get there error messages.

Do you habe any suggestions?
Thx a lot

TTraceback (most recent call last):
File "/Users/peter/Documents/Python3_Scripts/Easylist-proxypac/easylist_pac Kopie ORIGINAL.py", line 2426, in
badregex_regex_filters_re = re.compile(r'(?:{})'.format('|'.join(badregex_regex_filters.split('\n'))),re.IGNORECASE)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py", line 233, in compile
return _compile(pattern, flags)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py", line 301, in _compile
p = sre_compile.compile(pattern, flags)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_compile.py", line 562, in compile
p = sre_parse.parse(p, flags)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_parse.py", line 856, in parse
p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, False)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_parse.py", line 415, in _parse_sub
itemsappend(_parse(source, state, verbose))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_parse.py", line 763, in _parse
p = _parse_sub(source, state, sub_verbose)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_parse.py", line 415, in _parse_sub
itemsappend(_parse(source, state, verbose))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_parse.py", line 501, in _parse
code = _escape(source, this, state)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_parse.py", line 401, in _escape
raise source.error("bad escape %s" % escape, len(escape))
sre_constants.error: bad escape \m at position 16919

Would you please try the latest refactored commit? I didn't address this issue, but I'd like to ensure that nothing else broke.

Hi again,
I just had the time to run your script again (from July 07). Still some errors. Don't mind the wrong date in the filename.

RESTART: /Users/peter/Documents/Python3_Scripts/Easylist-proxypac/17.07.12_easylist_pac.py
No module named 'matplotlib'

Warning (from warnings module):
File "/Users/peter/Documents/Python3_Scripts/Easylist-proxypac/17.07.12_easylist_pac.py", line 32
warnings.warn("Install scikit-learn for more accurate EasyList rule selection.")
UserWarning: Install scikit-learn for more accurate EasyList rule selection.
Ignore rules following comment " Russian rating sites"…
4 rules ignored.
Ignore rules following comment " German"… " French"… " Armenian"… " Bulgarian"… " Chinese"… " Croatian"… " Czech"… " Danish"… " Dutch"… " Estonian"… " Finnish"… " Greek"… " Hebrew"… " Hungarian"… " Icelandic"… " Italian"… " Japanese"… " Korean"… " Latvian"… " Lithuanian"… " Norwegian"… " Persian"… " Polish"… " Portuguese"… " Romanian"… " Russian"… " Singaporean"… " Slovak"… " Spanish"… " Swedish"… " Thai"… " Turkish"… " Ukranian"… " Vietnamese"…
749 rules ignored.
Ignore rules following comment " German"… " Arabic"… " French"… " Belarusian"… " Croatian"… " Chinese"… " Croatian"… " Czech"… " Danish"… " Dutch"… " Estonian"… " Finnish"… " Georgian"… " Greek"… " Hebrew"… " Hungarian"… " Indonesian"… " Italian"… " Japanese"… " Korean"… " Latvian"… " Lithuanian"… " Norwegian"… " Polish"… " Portuguese"… " Romanian"… " Russian"… " Serbian"… " Slovak"… " Slovene"… " Spanish"… " Swedish"… " Turkish"… " Ukranian"…
604 rules ignored.
Ignore rules following comment " German"… " French"… " Arabic"… " Bulgarian"… " Chinese"… " Croatian"… " Czech"… " Dutch"… " Finnish"… " Greek"… " Hebrew"… " Hungarian"… " Italian"… " Japanese"… " Korean"… " Latvian"… " Norwegian"… " Persian"… " Polish"… " Portuguese"… " Russian"… " Serbian"… " Slovene"… " Spanish"… " Swedish"… " Turkish"… " Ukrainian"…
743 rules ignored.
Ignore rules following comment " Gamestar.de"… " Focus.de"… " tvspielfilm.de"… " Prosieben"… " Wetter.com"… " Woxikon.de"… " Fanfiktion.de"… " boote-forum.de"… " comunio.de"… " planetsnow.de"…
62 rules ignored.
Ignore rules following comment " German"… " French"… " Bulgarian"… " Chinese"… " Czech"… " Danish"… " Dutch"… " Finnish"… " Greek"… " Hebrew"… " Hungarian"… " Italian"… " Indonesian"… " Japanese"… " Latvian"… " Norwegian"… " Polish"… " Portuguese"… " Indian"… " Romanian"… " Russian"… " Spanish"… " Swedish"… " Thai"… " Turkish"… " Ukrainian"…
276 rules ignored.
Ignore rules following comment " adinsertion used on gizmodo.in lifehacker.co.in"…
1 rules ignored.
Traceback (most recent call last):
File "/Users/peter/Documents/Python3_Scripts/Easylist-proxypac/17.07.12_easylist_pac.py", line 1785, in
res = EasyListPAC()
File "/Users/peter/Documents/Python3_Scripts/Easylist-proxypac/17.07.12_easylist_pac.py", line 40, in init
self.parse_and_filter_rule_files()
File "/Users/peter/Documents/Python3_Scripts/Easylist-proxypac/17.07.12_easylist_pac.py", line 119, in parse_and_filter_rule_files
self.easylist_append_rules(fd)
File "/Users/peter/Documents/Python3_Scripts/Easylist-proxypac/17.07.12_easylist_pac.py", line 124, in easylist_append_rules
for line in fd:
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position 5127: ordinal not in range(128)

Please try the latest commit.

Hi again,

just tried and got this:

Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.

RESTART: /Users/peter/Documents/Python3_Scripts/Easylist-proxypac/13./easylist-pac-privoxy-master/easylist_pac.py
No module named 'numpy'

Warning (from warnings module):
File "/Users/peter/Documents/Python3_Scripts/Easylist-proxypac/13./easylist-pac-privoxy-master/easylist_pac.py", line 32
warnings.warn("Install scikit-learn for more accurate EasyList rule selection.")
UserWarning: Install scikit-learn for more accurate EasyList rule selection.
No module named 'matplotlib'

Warning (from warnings module):
File "/Users/peter/Documents/Python3_Scripts/Easylist-proxypac/13./easylist-pac-privoxy-master/easylist_pac.py", line 54
warnings.warn("Install matplotlib to plot rule priorities.")
UserWarning: Install matplotlib to plot rule priorities.
Ignore rules following comment " Russian rating sites"…
4 rules ignored.
Ignore rules following comment " German"… " French"… " Armenian"… " Bulgarian"… " Chinese"… " Croatian"… " Czech"… " Danish"… " Dutch"… " Estonian"… " Finnish"… " Greek"… " Hebrew"… " Hungarian"… " Icelandic"… " Italian"… " Japanese"… " Korean"… " Latvian"… " Lithuanian"… " Norwegian"… " Persian"… " Polish"… " Portuguese"… " Romanian"… " Russian"… " Singaporean"… " Slovak"… " Spanish"… " Swedish"… " Thai"… " Turkish"… " Ukranian"… " Vietnamese"…
749 rules ignored.
Ignore rules following comment " German"… " Arabic"… " French"… " Belarusian"… " Croatian"… " Chinese"… " Croatian"… " Czech"… " Danish"… " Dutch"… " Estonian"… " Finnish"… " Georgian"… " Greek"… " Hebrew"… " Hungarian"… " Indonesian"… " Italian"… " Japanese"… " Korean"… " Latvian"… " Lithuanian"… " Norwegian"… " Polish"… " Portuguese"… " Romanian"… " Russian"… " Serbian"… " Slovak"… " Slovene"… " Spanish"… " Swedish"… " Turkish"… " Ukranian"…
604 rules ignored.
Ignore rules following comment " German"… " French"… " Arabic"… " Bulgarian"… " Chinese"… " Croatian"… " Czech"… " Dutch"… " Finnish"… " Greek"… " Hebrew"… " Hungarian"… " Italian"… " Japanese"… " Korean"… " Latvian"… " Norwegian"… " Persian"… " Polish"… " Portuguese"… " Russian"… " Serbian"… " Slovene"… " Spanish"… " Swedish"… " Turkish"… " Ukrainian"…
743 rules ignored.
Ignore rules following comment " Gamestar.de"… " Focus.de"… " tvspielfilm.de"… " Prosieben"… " Wetter.com"… " Woxikon.de"… " Fanfiktion.de"… " boote-forum.de"… " comunio.de"… " planetsnow.de"…
62 rules ignored.
Ignore rules following comment " German"… " French"… " Bulgarian"… " Chinese"… " Czech"… " Danish"… " Dutch"… " Finnish"… " Greek"… " Hebrew"… " Hungarian"… " Italian"… " Indonesian"… " Japanese"… " Latvian"… " Norwegian"… " Polish"… " Portuguese"… " Indian"… " Romanian"… " Russian"… " Spanish"… " Swedish"… " Thai"… " Turkish"… " Ukrainian"…
276 rules ignored.
Ignore rules following comment " adinsertion used on gizmodo.in lifehacker.co.in"…
1 rules ignored.
Traceback (most recent call last):
File "/Users/peter/Documents/Python3_Scripts/Easylist-proxypac/13./easylist-pac-privoxy-master/easylist_pac.py", line 1876, in
res = EasyListPAC()
File "/Users/peter/Documents/Python3_Scripts/Easylist-proxypac/13./easylist-pac-privoxy-master/easylist_pac.py", line 63, in init
self.parse_and_filter_rule_files()
File "/Users/peter/Documents/Python3_Scripts/Easylist-proxypac/13./easylist-pac-privoxy-master/easylist_pac.py", line 144, in parse_and_filter_rule_files
self.easylist_append_rules(fd)
File "/Users/peter/Documents/Python3_Scripts/Easylist-proxypac/13./easylist-pac-privoxy-master/easylist_pac.py", line 149, in easylist_append_rules
for line in fd:
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position 5750: ordinal not in range(128)

I don't see that with my python 3.6.

Would you please add a line to your code to print the rule and report the rule on which it's failing?

Please try the latest commit. I had an issue like this while piping to an ASCII output.

Hi again,

I just run your script from latest commit and got these results:

Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.

RESTART: /Users/peter/Documents/Python3_Scripts/Easylist-proxypac/25.Juli/easylist-pac-privoxy-master/easylist_pac.py
No module named 'numpy'

Warning (from warnings module):
File "/Users/peter/Documents/Python3_Scripts/Easylist-proxypac/25.Juli/easylist-pac-privoxy-master/easylist_pac.py", line 32
warnings.warn("Install scikit-learn for more accurate EasyList rule selection.")
UserWarning: Install scikit-learn for more accurate EasyList rule selection.
No module named 'matplotlib'

Warning (from warnings module):
File "/Users/peter/Documents/Python3_Scripts/Easylist-proxypac/25.Juli/easylist-pac-privoxy-master/easylist_pac.py", line 54
warnings.warn("Install matplotlib to plot rule priorities.")
UserWarning: Install matplotlib to plot rule priorities.
Ignore rules following comment " Russian rating sites"…
4 rules ignored.
Ignore rules following comment " German"… " French"… " Armenian"… " Bulgarian"… " Chinese"… " Croatian"… " Czech"… " Danish"… " Dutch"… " Estonian"… " Finnish"… " Greek"… " Hebrew"… " Hungarian"… " Icelandic"… " Indonesian"… " Italian"… " Japanese"… " Korean"… " Latvian"… " Lithuanian"… " Norwegian"… " Persian"… " Polish"… " Portuguese"… " Romanian"… " Russian"… " Singaporean"… " Slovak"… " Spanish"… " Swedish"… " Thai"… " Turkish"… " Ukranian"… " Vietnamese"…
767 rules ignored.
Ignore rules following comment " German"… " Arabic"… " French"… " Belarusian"… " Croatian"… " Chinese"… " Croatian"… " Czech"… " Danish"… " Dutch"… " Estonian"… " Finnish"… " Georgian"… " Greek"… " Hebrew"… " Hungarian"… " Indonesian"… " Italian"… " Japanese"… " Korean"… " Latvian"… " Lithuanian"… " Norwegian"… " Polish"… " Portuguese"… " Romanian"… " Russian"… " Serbian"… " Slovak"… " Slovene"… " Spanish"… " Swedish"… " Thai"… " Turkish"… " Ukranian"… " Vietnamese"…
618 rules ignored.
Ignore rules following comment " German"… " French"… " Arabic"… " Bulgarian"… " Chinese"… " Croatian"… " Czech"… " Dutch"… " Finnish"… " Greek"… " Hebrew"… " Hungarian"… " Italian"… " Japanese"… " Korean"… " Latvian"… " Norwegian"… " Persian"… " Polish"… " Portuguese"… " Russian"… " Serbian"… " Slovene"… " Spanish"… " Swedish"… " Turkish"… " Ukrainian"…
763 rules ignored.
Ignore rules following comment " Gamestar.de"… " Focus.de"… " tvspielfilm.de"… " Prosieben"… " Wetter.com"… " Woxikon.de"… " Fanfiktion.de"… " boote-forum.de"… " comunio.de"… " planetsnow.de"…
62 rules ignored.
Ignore rules following comment " German"… " French"… " Bulgarian"… " Chinese"… " Czech"… " Danish"… " Dutch"… " Finnish"… " Greek"… " Hebrew"… " Hungarian"… " Italian"… " Indonesian"… " Japanese"… " Latvian"… " Norwegian"… " Polish"… " Portuguese"… " Indian"… " Romanian"… " Russian"… " Spanish"… " Swedish"… " Thai"… " Turkish"… " Ukrainian"…
280 rules ignored.
Ignore rules following comment " adinsertion used on gizmodo.in lifehacker.co.in"…
1 rules ignored.
Ignore rules following comment " shink.in"…
6 rules ignored.
Ignore rules following comment " project-free-tv.li"…
3 rules ignored.
Ignore rules following comment " vshare.eu"… " pencurimovie.ph"… " filmlinks4u.is"…
9 rules ignored.
Ignore rules following comment " Spiegel.de"… " bento.de"…
51 rules ignored.
Ignore rules following comment " Healthy Advertising (Spanish)"…
1 rules ignored.
Traceback (most recent call last):
File "/Users/peter/Documents/Python3_Scripts/Easylist-proxypac/25.Juli/easylist-pac-privoxy-master/easylist_pac.py", line 1875, in
res = EasyListPAC()
File "/Users/peter/Documents/Python3_Scripts/Easylist-proxypac/25.Juli/easylist-pac-privoxy-master/easylist_pac.py", line 63, in init
self.prioritize_rules()
File "/Users/peter/Documents/Python3_Scripts/Easylist-proxypac/25.Juli/easylist-pac-privoxy-master/easylist_pac.py", line 224, in prioritize_rules
self.good_signal = np.array([self.good_class_test(x,opts) for (x,opts,f) in zip(self.good_rules,self.good_opts,self.good_rules_include_flag) if f], dtype=np.int)
NameError: name 'np' is not defined

Please pull the latest.

You will need to have numpy installed with your Python distro.