pythonprofilers / memory_profiler

Monitor Memory usage of Python code
http://pypi.python.org/pypi/memory_profiler
Other
4.39k stars 380 forks source link

Fix UnicodeDecodeError during installation #340

Closed henryfung3a27 closed 2 years ago

henryfung3a27 commented 2 years ago

The files README.rst and memory_profiler.py contain invalid characters for python to decode when setup.py is trying to read them. The quotes in “Resident Set Size” are Unicode characters 0xe2809c and 0xe2809d, whereas the standard ascii quote is " with ascii code 22.

Using pip install memory_profiler --user will get the cached version memory_profiler-0.59.0.tar.gz (38 kB), which contains the special quotes. pip will fail the installation and use a fallback cached version memory_profiler-0.58.0.tar.gz (36 kB).

The complete error is as follow:

Traceback (most recent call last):
  File "D:\share\memory_profiler-master\memory_profiler-master\setup.py", line 33, in <module>
    long_description=open('README.rst').read(),
UnicodeDecodeError: 'cp950' codec can't decode byte 0xe2 in position 14818: illegal multibyte sequence

and

Traceback (most recent call last):
  File "D:\share\memory_profiler-master\memory_profiler-master\setup.py", line 34, in <module>
    version=find_version("memory_profiler.py"),
  File "D:\share\memory_profiler-master\memory_profiler-master\setup.py", line 8, in find_version
    version_file = f.read()
UnicodeDecodeError: 'cp950' codec can't decode byte 0xe2 in position 10853: illegal multibyte sequence

Changing the quotes back to standard ascii fixes the error.

Environment

OS: Windows 10 Python: 3.8.10 and 3.10.0

fabianp commented 2 years ago

thanks @henryfung3a27 !