pyminifier
pyminifier copied to clipboard
pyminifier keeps defaulting to Python 2.7 though I have Python 3 installed
Hello, Not sure if this is an issue or expected behavior. I have read the docs, but cannot find any solution. I have two problems with seeming related root cause - pyminifier keeps invoking python 2.7 and when I have python 3 features, I get errors.
I am running Mac OSX and have the native python 2.7 as well as python 3.6.1 installed. My .bash_profile aliases "python" to "python3". I dont seem to have any problems.
Scenario 1: I ran the following command at command line: $ pyminifier --obfuscate --gzip --outfile=tmp.py DB_Analyzer_v2.py
I get the following error. It's clearly due to python3 specific features:
Traceback (most recent call last):
File "/usr/local/bin/pyminifier", line 11, in <module>
sys.exit(main())
File "/Library/Python/2.7/site-packages/pyminifier/pyminifier.py", line 423, in main
f = open(options.outfile, 'w', encoding='utf-8')
TypeError: 'encoding' is an invalid keyword argument for this function
Scenario 2: When I try to replace with non-latin characters, I also get a v2.7 related error:
$ pyminifier --nonlatin --replacement-length=50 DB_Analyzer_v2.py
ERROR: You can't use nonlatin characters without Python 3
Traceback (most recent call last):
File "/usr/local/bin/pyminifier", line 11, in <module>
sys.exit(main())
File "/Library/Python/2.7/site-packages/pyminifier/pyminifier.py", line 408, in main
obfuscate.obfuscate(module, tokens, options)
File "/Library/Python/2.7/site-packages/pyminifier/obfuscate.py", line 692, in obfuscate
table
File "/Library/Python/2.7/site-packages/pyminifier/obfuscate.py", line 292, in replace_obfuscatables
replacement = next(name_generator)
TypeError: NoneType object is not an iterator
Both of my errors seem to be due to a mix-up between pyminifier relying on v2.7 vs 3.6. I removed the alias from my bash_profile, but that did not help either.
Any suggestions on how I can solve this?
Thanks.
I have got the same problem. Did you manage to solve this?
I have a problem where it sticks to python 3.5 even though i installed it using pip for python2.7 Any updates on this issue?
In master branch, following problem has been fixed.
File "/root/py27/local/lib/python2.7/site-packages/pyminifier/pyminifier.py", line 423, in main
f = open(options.outfile, 'w', encoding='utf-8')
TypeError: 'encoding' is an invalid keyword argument for this function
For more detail, please see the commit pyminifier.py: Fixed a bug with file saving using Python 2.
Maybe we need pyminifier
2.2, but it's not released.(PyPI only has 2.1)
Try
pip install git+https://github.com/liftoff/pyminifier.git
to solve it.