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

pip install nanosv: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 1112: ordinal not in range(128) #45

Closed
philres opened this issue Jun 27, 2018 · 5 comments

Comments

@philres
Copy link

philres commented Jun 27, 2018

Hi,

I tried installing nanosv via pip and got the following error:

root@b9549bcea748:/# pip3 install nanosv
Collecting nanosv
  Using cached https://files.pythonhosted.org/packages/42/f8/48ea99c79d98b19b4d91fda2cfdfbd596510ae0a1205a706a31221dfab78/NanoSV-1.2.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-mkp3zu0i/nanosv/setup.py", line 16, in <module>
        long_description=readme(),
      File "/tmp/pip-build-mkp3zu0i/nanosv/setup.py", line 10, in readme
        return f.read()
      File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode
        return codecs.ascii_decode(input, self.errors)[0]
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 1112: ordinal not in range(128)
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-mkp3zu0i/nanosv/
You are using pip version 8.1.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

In case you want to reproduce it, this is the docker image I used:

FROM ubuntu:16.04
MAINTAINER prescheneder

RUN apt-get update \
    && apt-get install --no-install-recommends -y \
        python3 \
        python3-pip \
        python3-dev \
        build-essential \
        git \
        cmake \
        wget \
        libz-dev \
        libncurses-dev \
        libbz2-dev \
        liblzma-dev \
    && pip3 --no-cache-dir install --upgrade \
        setuptools \
        wheel

It is not a problem for me as the following worked, just wanted to let you know.

git clone https://github.com/mroosmalen/nanosv.git \
cd nanosv/ \
touch README.rst \
pip3 install .

Only small hiccup there, was that I had to create the README.rst

Philipp

@philres
Copy link
Author

philres commented Jun 27, 2018

Ok I have to take that back it is a problem, because if I try running NanoSV with data and not only NanoSV -h I get the same error:

$ NanoSV test.bam -o test_nanosv.vcf 
Traceback (most recent call last):
  File "/usr/local/bin/NanoSV", line 11, in <module>
    load_entry_point('NanoSV==1.2.0', 'console_scripts', 'NanoSV')()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 476, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2700, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2318, in load
    return self.resolve()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2324, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python3.5/dist-packages/nanosv/__init__.py", line 1, in <module>
    from .utils import *
  File "/usr/local/lib/python3.5/dist-packages/nanosv/utils/__init__.py", line 1, in <module>
    from . import coverage
  File "/usr/local/lib/python3.5/dist-packages/nanosv/utils/coverage.py", line 8, in <module>
    import NanoSV
  File "/usr/local/lib/python3.5/dist-packages/nanosv/utils/../NanoSV.py", line 29, in <module>
    cfg.read(args.config)
  File "/usr/lib/python3.5/configparser.py", line 696, in read
    self._read(fp, filename)
  File "/usr/lib/python3.5/configparser.py", line 1012, in _read
    for lineno, line in enumerate(fp, start=1):
  File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 948: ordinal not in range(128)

@mroosmalen
Copy link
Owner

This is because of the encoding language.
If you use bash as your shell, you can put these lines in your ~/.bashrc and ~/.profile files

export LC_CTYPE=en_US.UTF-8
export LANG=en_US.UTF-8

@philres
Copy link
Author

philres commented Jun 27, 2018

Hi Mark,

Thanks for the quick reply. For the record, changing the Dockerfile to the following fixed it:

FROM ubuntu:16.04

ENV LC_CTYPE en_US.UTF-8
ENV LANG en_US.UTF-8

RUN apt-get update \
    && apt-get install --no-install-recommends -y \
        language-pack-en \
        python3 \
        python3-pip \
        python3-dev \
        build-essential \
        git \
        cmake \
        wget \
        libz-dev \
        libncurses-dev \
        libbz2-dev \
        liblzma-dev \
    && pip3 --no-cache-dir install --upgrade \
        setuptools \
        wheel

@Asa-Nisi-Masa
Copy link

Asa-Nisi-Masa commented Jun 17, 2020

What worked for me was LC_ALL=C.UTF-8 pip3 install nanosv (for a different package)

@Varun-garg
Copy link

combining all answers, adding following to Dockerfile worked for me (arch linux)

# this is required for some systems
ENV LC_ALL=C.UTF-8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants