ip-tools / uspto-opendata-python

A client library for accessing the USPTO Open Data APIs, written in Python.
https://docs.ip-tools.org/uspto-opendata-python/
MIT License
88 stars 23 forks source link

In windows it gives codec UnicodeDecodeError:. #1

Closed rahul-gj closed 6 years ago

rahul-gj commented 6 years ago

I tried cmd, powershell, ipython-qt-console, and cygwin.

this is the cygwin output. others are same.

$ pip install uspto-opendata-python
Collecting uspto-opendata-python
  Using cached uspto-opendata-python-0.7.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\cygwin64\tmp\pip-build-irgg6e4i\uspto-opendata-python\setup.py", line 5, in <module>
        README = open(os.path.join(here, 'README.rst')).read()
      File "C:\Users\user\WinPython-32bit-3.6.2.0Qt5\python-3.6.2\lib\encodings\cp1252.py", line 23, in decode
        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
    UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 4791: character maps to <undefined>

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\cygwin64\tmp\pip-build-irgg6e4i\uspto-opendata-python\
amotl commented 6 years ago

Dear Rahul,

thanks for spotting this. I replaced two non ASCII-compatible quotation marks in the README file and uploaded a new patch release (version 0.7.3) to PyPI.

Can i ask you to try again?

With kind regards, Andreas.

rahul-gj commented 6 years ago

Thanks. But it still gives me error while at 'CHANGES = open(os.path.join(here, 'CHANGES.rst')).read()'

I suggest you should use:

with open(os.path.join(here, 'CHANGES.rst'), encoding='utf-8') as f:
    CHANGES = f.read()

everywhere. This takes care of unicode for me most of the time.

amotl commented 6 years ago

Bummer.

Thanks for your suggestion! Unfortunately, Python2 doesn't provide the encoding kwarg to the open builtin yet. codecs.open would be the way to go here.

I will improve this and also might take a look what the culprit in CHANGES.rst actually is.

Thanks again for your patience!

amotl commented 6 years ago

Hi Rahul,

i just fixed the offending characters in CHANGES.rst and uploaded version 0.7.4 to PyPI. May i ask you to try again?

Best, Andreas.

rahul-gj commented 6 years ago

Successfully installed on 64bit win10 PC

amotl commented 6 years ago

Thanks for letting me know.

You are welcome to come back for any further issues you might encounter. This project was conceived only recently and doesn't have a large user base yet, so i am happy if others would find rough edges and bugs which slipped through or i am having a blind spot for.