qpython-android / qpython.org

QPython contributor & sugguestion & question homepage
http://qpython.org
58 stars 11 forks source link

pip: configargparse: 'ascii' codec can't decode byte 0x80...: ordinal not in range(128) #157

Open kaiof opened 7 years ago

kaiof commented 7 years ago

QPython 1.0.0 / Python 3.2.2 - no later version in Play store; couldn't find 1.2.3.

The error in the title (reporting an "invalid header") occurs when attempting to "pip install mitmproxy"

It's coming from nti() in tarfile.py, which has a bug for packages coming from Windows systems (or anywhere the uid/gid aren't set):

https://bugs.python.org/issue24514
https://bugs.python.org/msg245844
https://bugs.python.org/file39815/issue24514.diff

It's resolved by adding rstrip() at line 178, so I patched but that wasn't it:

- n = int(nts(s, "ascii", "strict") or "0", 8) 
+ n = int(nts(s, "ascii", "strict").rstrip() or "0", 8)

...though it seems like that change should probably be there. So I found another potential cause:

https://github.com/PyMySQL/PyMySQL/issues/176 https://github.com/PyMySQL/PyMySQL/issues/207#issuecomment-32720297

This might be fixed (second link says 3.3 was the first version to support unicode strings) by setting the file encoding (utf-8) marker on every file and removing 'u' from strings (but I'm not familiar enough to intercept this during pip) or possibly by importing 'future' (first link) and adding unicode support:

from future import unicode_literals

but the 'future' module is not provided in QPython3.

'mitmproxy' is ridiculously useful when developing apps on an Android phone. Is there any way the underlying Python version can be bumped up (or since you know your app better, somehow fix this?)

rvilla87 commented 7 years ago

I'm interested also in installing mitmproxy in android, did you do it finally? I also have the same error with 1.0.3 release.

I tried 1.3.0 beta 2 release that uses Python 3.6 but I have 2 new errors (depending which library I try to install): ImportError: No module named _ctypes operation not permitted

With 1.0.3 I can import ctypes but I can't do it with 1.3.0 beta 2 version.

Hope in next version they fix it.