Installing gensim on Ubuntu 15.10/Python 3.5
Yay, another story of a package which surprisingly fails to install! :)
Part 1 (Problem): Installing httpretty
> sudo pip3.5 install gensim
Collecting httpretty==0.8.6 (from smart-open>=1.2.1->gensim)
Using cached httpretty-0.8.6.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
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 0xc3 in position 133: ordinal not in range(128)
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-wwjm5awu/httpretty
An classic example of an UnicodeDecodeError. Such a rare encounter in the wild... Oh, how nice would that be ;)
Part 1 (Fix): Changing the system-locale
Obviously there is a problem with the locale, so let’s find out what it’s set to
LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
Seems like an ASCII-locale is used. We need to find a replacement for that, so list all currently installed locales
> locale -a
C
C.UTF-8
en_US.utf8
POSIX
Wow, a perfect opportunity! Let’s use that smexy UTF-8 locale :)
> update-locale LC_ALL=en_US.utf8
Now log out and back in. It should successfully install httpretty now. For me, SciPy failed to install, too, so there we go:
Part 2 (Problem): Installing SciPy
> sudo pip3.5 install gensim
Atlas (http://math-atlas.sourceforge.net/) libraries not found. [...]
Lapack (http://www.netlib.org/lapack/) libraries not found. [...]
Lapack (http://www.netlib.org/lapack/) sources not found. [...]
numpy.distutils.system_info.NotFoundError: no lapack/blas resources found [...]
Failed building wheel for scipy
Successfully built gensim smart-open httpretty bz2file
Installing collected packages: scipy, boto, httpretty, bz2file, smart-open, gensim
Running setup.py install for scipy
numpy.distutils.system_info.NotFoundError: no lapack/blas resources found
----------------------------------------
Command "/usr/bin/python3.5 -c "import setuptools, tokenize;__file__='/tmp/pip-build-j601bm8w/scipy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-4_fhi6ho-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-j601bm8w/scipy
Part 2 (Fix): Installing packages for BLAS and LAPACK
Somehow I couldn’t get these instructions to work, so I went with these:
> sudo apt-get install gfortran libopenblas-dev liblapack-dev
Now the Installation worked like a charm.
The pip-package gensim failed to install because of the dependency httpretty trying to print to a non-UTF-8 locale and the dependency SciPy failing to find OpenBLAS/Lapack-Libraries.
BTW, installing the gensim-package took approximately 3/4hrs (leaving out the time needed for finding error-fixes).