-
Notifications
You must be signed in to change notification settings - Fork 358
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
Make fails with UnicodeDecodeError #830
Comments
It seems to be an encoding issue - explained quite well here. Funnily enough, I don't see it neither with python2 nor python3 on Fedora 26 here, so could be something to do with the system defaults there? Maybe check your default encodings? In a python interpreter, |
It is an encoding problem, my problem is that I do not know how to avoid it properly. I too have ascii for python2 and utf-8 for python3. For now I circumvented the problem as I said above and have nest installed and running, for the future it would be nice to know how to force python encoding during cmake configuration generation. |
@steffengraber Could you take a look at this? I assume the problem occurs because some
|
@heplesser We can use the |
We can use the following to scan the code base for files that are not valid UTF-8 files: for r, d, f in os.walk('.'):
for fn in f:
try:
open(os.path.join(r, fn), 'r', encoding='utf-8').read()
except:
print('Error:', os.path.join(r, fn)) |
@heplesser: Thanks for the code. Here's my extended version, which should work with Python 2 and 3: import os
from io import open
exclude_paths = [".git"]
exclude_files = [".jpg", ".pdf", ".png"]
for r, d, f in os.walk('.'):
for fn in f:
check = True
for ep in exclude_paths:
if r.startswith(os.path.join(".", ep)):
check = False
break
for ef in exclude_files:
if fn.endswith(ef):
check = False
break
if check:
try:
open(os.path.join(r, fn), 'r', encoding='utf-8').read()
except:
print('Error:', os.path.join(r, fn)) On my machine (Ubuntu 17.04), this does not report any errors. @Spielzeug, can you please save the code to a file in the NEST source directory on your machine and execute it? Thanks! |
@jougs : I tried it with my own fresh compiled python 3.6.3, but I don't get any output:
OR
But I get the same compile error:
EDIT: bla.py is your code + |
@jougs : Sorry, forgot, that I already deleted the build dir. Here are the files:
|
Any updates on this? I'm getting the same error when running make install on both Python 3.5.4 and 2.7 in Ubuntu 16.04, so the above workaround does not work. |
@krisdamato That's what I did in detail: Install the dependencies:
Getting NEST
Installing NEST with Python 2
or: Installing NEST with Python 3
Could you please explain exactly what you did? |
I was using an ubuntu image from their official Docker repository, creating
a conda environment, and building. I can't recall the exact steps, because
now I've fixed it by using a different image. My apologies.
On an unrelated note: providing an official NEST simulator docker image
would be really cool for people who need to set this up on private
clusters/home machines.
…On Tue, Jan 9, 2018 at 8:00 AM, graber ***@***.***> wrote:
@krisdamato <https://github.com/krisdamato>
I tried it with a fresh install of Ubuntu 16.04.3 with all the latest
updates (Python 2.7.12, Python 3.5.2) in a Virtualbox and could not
reproduce your problems.
Additionally I tried Python 3.6.4. Even with that I could not create the
error.
That's what I did in detail:
Install the dependencies:
sudo apt-get install -y build-essential cmake libltdl-dev libreadline6-dev
libncurses5-dev libgsl-dev python-all-dev python-numpy python-scipy
python-matplotlib ipython openmpi-bin libopenmpi-dev python-nose cython
Getting NEST
wget https://github.com/nest/nest-simulator/archive/master.zip
unzip master.zip
mkdir build
mkdir install
cd build
Installing NEST with Python 2
cmake -DCMAKE_INSTALL_PREFIX:PATH=../install -Dwith-python=2 -DPYTHON_EXECUTABLE=/usr/bin/python2 ../nest-simulator-master
make
make install
or: Installing NEST with Python 3
cmake -DCMAKE_INSTALL_PREFIX:PATH=../install -Dwith-python=3 -DPYTHON_EXECUTABLE=/usr/bin/python3 ../nest-simulator-master
make
make install
Could you please explain exactly what you did?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#830 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGjleHuN4vQrM3tgYXfaLosfwCK1qxgPks5tIw5-gaJpZM4Ph4Ml>
.
|
@krisdamato An official docker image is in preparation. |
I tried the installation with non-UTF-8 |
@steffengraber: can you please run the code from my comment with the non-unicode locale and see if there are files with errors? Thanks! |
@jougs Sorry, checked again in new master with python 2 and 3. No errors. |
@steffengraber : could you add an |
Because encoding='utf-8' as argument to open() won't run under Python2 I decided to use the io-module (io.open(file”, “r”, encoding=”utf-8”)). |
Fixed by #915. |
Under archlinux, make fails either using python2 or python3:
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DPYTHON_EXECUTABLE=/usr/bin/python2 -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/libpython2.7.so -DPYTHON_BASENAME=-python2.7 ../nest-2.12.0
OR
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DPYTHON_EXECUTABLE=/usr/bin/python -DPYTHON_INCLUDE_DIR=/usr/include/python3.6 -DPYTHON_LIBRARY=/usr/lib/libpython3.6.so -DPYTHON_BASENAME=-python3.6 ../nest-2.12.0
CMake output: https://pastebin.com/3esMhsM7
after this make command fails with:
Traceback (most recent call last):
File "generate_help.py", line 76, in
filetext = f.read()
File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1128: ordinal not in range(128)
make[2]: *** [doc/CMakeFiles/generate_help.dir/build.make:58: generate_help] Error 1
make[1]: *** [CMakeFiles/Makefile2:216: doc/CMakeFiles/generate_help.dir/all] Error 2
make: *** [Makefile:163: all] Error 2
Tested the generate_help.py invokation with python2 and python3, it works with python2. Had to change cmake generated build.make:
generate_help: doc/CMakeFiles/generate_help.dir/build.make
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --blue --bold "Extracting help information; this may take a litte while."
cd /home/rei/Downloads/nest-2.12.0/extras/help_generator && python -B generate_help.py /home/rei/Downloads/nest-2.12.0 /home/rei/Downloads/nest-build
cd /home/rei/Downloads/nest-2.12.0/extras/help_generator && python -B generate_helpindex.py /home/rei/Downloads/nest-build/doc
.PHONY : generate_help
to
generate_help: doc/CMakeFiles/generate_help.dir/build.make
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --blue --bold "Extracting help information; this may take a litte while."
cd /home/rei/Downloads/nest-2.12.0/extras/help_generator && python2 -B generate_help.py /home/rei/Downloads/nest-2.12.0 /home/rei/Downloads/nest-build
cd /home/rei/Downloads/nest-2.12.0/extras/help_generator && python2 -B generate_helpindex.py /home/rei/Downloads/nest-build/doc
.PHONY : generate_help
Can someone point out what should I have done to avoid this messy change?
The text was updated successfully, but these errors were encountered: