Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 2 not yet supported #1

Closed
jayvdb opened this issue Aug 28, 2019 · 7 comments
Closed

Python 2 not yet supported #1

jayvdb opened this issue Aug 28, 2019 · 7 comments
Labels
help wanted Extra attention is needed

Comments

@jayvdb
Copy link
Contributor

jayvdb commented Aug 28, 2019

Traceback:
test/test_on_file.py:5: in <module>
    from charset_normalizer import CharsetNormalizerMatches as CnM
charset_normalizer/__init__.py:2: in <module>
    from charset_normalizer.normalizer import CharsetNormalizerMatches, CharsetNormalizerMatch
charset_normalizer/normalizer.py:3: in <module>
    import statistics
E   ImportError: No module named statistics
@jayvdb
Copy link
Contributor Author

jayvdb commented Aug 28, 2019

Also seen on https://travis-ci.org/Ousret/charset_normalizer/jobs/577468690

There is a drop-in statistics backport which can be required only on py2. https://pypi.org/project/statistics

After that, the next py2 problem is ImportError: cannot import name lru_cache , which also has a backport, but it is in a different namespace so needs a try block https://pypi.org/project/backports.functools_lru_cache/

@jayvdb
Copy link
Contributor Author

jayvdb commented Aug 28, 2019

And then

AttributeError: 'str' object has no attribute 'isprintable'

and

File "../charset_normalizer/normalizer.py", line 239, in from_bytes
    str(sequences, encoding=p)
TypeError: str() takes at most 1 argument (2 given)

And test_should_be_accented failing for some reason.

@jayvdb
Copy link
Contributor Author

jayvdb commented Aug 28, 2019

'isprintable' is the hard one ... it will require a backport of py3 unicode to py2. There are a few of them - I used one in about 2015, but I suspect they may not be maintained very well as the usefulness and usage reduced.

@jayvdb
Copy link
Contributor Author

jayvdb commented Aug 28, 2019

https://pypi.org/project/unicodedata2/ is the one I was thinking about ; not sure it has isprintable . maybe need future for that?

@Ousret
Copy link
Owner

Ousret commented Aug 28, 2019

Hi,

I've tried the same and stopped at isprintable method support.
I'm looking/considering bulding my own isprintable method and add it to unicode helper class.

@jayvdb
Copy link
Contributor Author

jayvdb commented Aug 28, 2019

jayvdb added a commit to jayvdb/charset_normalizer that referenced this issue Aug 28, 2019
Add backports, and implement isprintable

Also add a few fixes for Python 2 unicode.

Related to Ousret#1
jayvdb added a commit to jayvdb/charset_normalizer that referenced this issue Aug 28, 2019
Add backports, and implement isprintable

Also add a few fixes for Python 2 unicode.

Related to Ousret#1
jayvdb added a commit to jayvdb/charset_normalizer that referenced this issue Aug 28, 2019
Add backports, and implement isprintable

Also add a few fixes for Python 2 unicode.

Related to Ousret#1
jayvdb added a commit to jayvdb/charset_normalizer that referenced this issue Aug 28, 2019
Add backports, and implement isprintable

Fixes Ousret#1
jayvdb added a commit to jayvdb/charset_normalizer that referenced this issue Sep 4, 2019
Add backports, and implement isprintable

Fixes Ousret#1
@Ousret Ousret added the help wanted Extra attention is needed label Sep 5, 2019
@Ousret Ousret changed the title Python 2 ImportError: No module named statistics Python 2 not yet supported Sep 6, 2019
@Ousret Ousret closed this as completed Oct 7, 2019
@Ousret
Copy link
Owner

Ousret commented Oct 7, 2019

See #5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants