UnicodeDecodeError from setup.py
Closed this issue · 6 comments
probably my setup, but happens on both my macbook and linux desktop at work (both with python 3)
p setup.py install --prefix=/Users/strange/qmlcode
MKL-discover: MKLROOT was not set
Traceback (most recent call last):
File "setup.py", line 170, in
setup_pepytools()
File "setup.py", line 149, in setup_pepytools
long_description = readme(),
File "setup.py", line 134, in readme
return f.read()
File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
Following seems to fix it:
diff --git a/setup.py b/setup.py
index 495f7e8..2ce0397 100755
--- a/setup.py
+++ b/setup.py
@@ -130,7 +130,7 @@ ext_fslatm = Extension(name = 'fslatm',
# use README.md as long description
def readme():
- with open('README.md') as f:
+ with open('README.md', encoding='latin1') as f:
return f.read()
Just to debug a little. Can you tell me the output of
python
>>> import sys
>>> sys.stdout.encoding
also see if any of these environmental variables are set:
echo $LANGUAGE
echo $LC_ALL
echo $LANG
echo $LC_TYPE
And finally check if the following fixes the issue:
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_TYPE=en_US.UTF-8
@andersx @charnley @SilviaAmAm I don't see a reason not to hardcode the encoding in the setup. I'm just concerned that using the wrong encoding might break some of the functionality of the file reader classes.
@mikstr Can you try to run pytest
in the test folder with your proposed fix and make sure that all tests passes? Also can you try to checkout the development branch and see if that solves the problem since I removed special characters like ü in the readme.
thanks @larsbratholm, I'll take a look at it this evening!
Thanks for the report! Does this also happen if you install directly from PyPI (e.g. pip install qml
)?
If that's the case we need to push a bug fix to master and PyPI.
@andersx installation fails with pip3 install qml
, works with pip2 install qml
the env variables req by @larsbratholm on my mac:
[qml]# echo $LANGUAGE
[qml]# echo $LC_ALL
C
[qml]# echo $LANG[qml]# echo $LC_TYPE
If I set the above variables to en_US.UTF-8
as suggested by @larsbratholm installation works with both pip2 and pip3 :-)
@mikstr Made a hotfix that removes the characters that causes trouble, so when that is accepted everything should work fine. To expand on this LC_ALL=C together with non-ascii characters like ü is what broke everything.