Python 3.7 - Issues Installing Scikit-Learn - python-3.x

I am currently encountering below issues when trying to install any version of Scikit Learn (0.19.0 or 0.19.1 or 0.19.2) for Python 3.7 or 2.7 on Linux - RHEL / Centos 7 OS.
Few months back I could successfully install scikit-learn under python 2.7 without issues. When I re-run the installation of scikit-learn package under python 2.7 its failing with the same below error.
I have installed all the required OS and Python package dependencies prior to installing the scikit-learn
I have installed all the prerequisite - OS packages - blas-devel , lapack-devel , atlas-devel.
Python Version - 3.7
/usr/local/bsb-python37 - Custom Location in which I configured and installed Python 3.7
Steps I followed to install Python and Python Packages.
Installed Python with below steps - Followed the same procedure for Python 2.7 and 3.7
Install Python 2.7
bash "build-and-install-python2.7" do
cwd '/tmp/python'
code <<-EOH
tar -xvf Python-2.7.14.tgz --no-same-owner / tar -xvf Python-3.7.0.tgz --no-same-owner
sleep 10
cd Python-2.7.14 / cd Python-3.7.0
./configure --prefix=/usr/local/bsb-python27 (and bsb-python37)
make && make altinstall
EOH
not_if { ::File.exist?('/usr/local/bsb-python27/bin/python2.7') }
end
Package Installation Steps
Install scikitlearn
bash "scikitlearn-install" do
cwd '/tmp/python'
code <<-EOH
tar xzvf scikit-learn-0.19.0.tar.gz or scikit-learn-0.19.1.tar.gz or scikit-learn-0.19.2.tar.gz
sleep 10
cd scikit-learn-0.19.1 or cd scikit-learn-0.19.1 or scikit-learn-0.19.2
/usr/local/bsb-python27/bin/python2.7 setup.py install --prefix=/usr/local/bsb-python27
EOH
not_if " /usr/local/bsb-python27/bin/python2.7 -c 'import sklearn;' "
end
Few months back when I installed scikit-learn under Python 2.7 I didn't run into any issues. Now when I re-try to install the scikit learn under Python 2.7 I am running into the same issue and the earlier successful installed version of scikit learn is corrupted.
Error Message :
/usr/local/bsb-python37/bin/python3.7 setup.py install --prefix=/usr/local/bsb-python37
Partial import of sklearn during the build process.
blas_opt_info:
blas_mkl_info:
customize UnixCCompiler
libraries mkl_rt not found in ['/usr/local/bsb-python37/lib', '/usr/local/lib64', '/usr/local/lib', '/usr/lib64', '/usr/lib', '/usr/lib/']
NOT AVAILABLE
blis_info:
customize UnixCCompiler
libraries blis not found in ['/usr/local/bsb-python37/lib', '/usr/local/lib64', '/usr/local/lib', '/usr/lib64', '/usr/lib', '/usr/lib/']
NOT AVAILABLE
error: Command "g++ -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/bsb-python37/lib/python3.7/site-packages/numpy-1.14.5-py3.7-linux-x86_64.egg/numpy/core/include -I/usr/local/bsb-python37/lib/python3.7/site-packages/numpy-1.14.5-py3.7-linux-x86_64.egg/numpy/core/include -I/usr/local/bsb-python37/include/python3.7m -c sklearn/cluster/_dbscan_inner.cpp -o build/temp.linux-x86_64-3.7/sklearn/cluster/_dbscan_inner.o -MMD -MF build/temp.linux-x86_64-3.7/sklearn/cluster/_dbscan_inner.o.d" failed with exit status 1
Any help is greatly appreciated. I tried to google around and did all that I could try. No luck.

I have just used pip install sklearn as an alternative. It worked for me.

Related

Installing cx_Oracle on 32 bit Anaconda: LONG_BIT definition appears wrong for platform

I am on a 64 bit machine, but need to support a legacy 32 bit proprietary system.
I have miniconda 32 bit installed version 3.7.1, as well as a 32 bit oracle client. My ORACLE_HOME and LD_LIBRARY_PATH are pointed to the correct 32 bit oracle client.
I cannot install a 64 bit python since I need to interact with 32 bit legacy C libraries.
It looks like miniconda's pip is attempting to install 64 bit cx_Oracle even though it is a 32 bit python installation.
pip install cx_Oracle results in the following error (edit: as well as python -m pip install cx_Oracle):
running bdist_wheel
running build
running build_ext
building 'cx_Oracle' extension
creating build
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/src
creating build/temp.linux-x86_64-3.7/odpi
creating build/temp.linux-x86_64-3.7/odpi/src
gcc -pthread -B /path/to/miniconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DCXO_BUILD_VERSION=7.3.0 -Iodpi/include -Iodpi/src -I/path/to/miniconda3/include/python3.7m -c src/cxoBuffer.c -o build/temp.linux-x86_64-3.7/src/cxoBuffer.o
/path/to/miniconda3/include/python3.7m/pyport.h:699:2: error:
#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
error: command 'gcc' failed with exit status 1
It seems that pip is attempting to install 64 bit cx_Oracle, even though this is a 32 bit python. For example the pip install cx_Oracle command shows x86_64 and is not using -m32 to build.
The same is true if I git clone an older version like cx_Oracle 5.3 and run python setup.py install.
How can I install 32 bit cx_Oracle on a 32 bit miniconda installation?
Installing it using conda (located in the miniconda's bin directory next to pip) works.
./conda install -c https://conda.anaconda.org/anaconda cx_oracle
I'm not sure why using pip tried to install a 64 bit version.

Build boost for python 3.5 under Ubuntu 18

I installed boost using apt-get. Programs see it fine when doing a bootstrap:
idf#ubvm:$ dpkg -s libboost-dev | grep Version
Version: 1.65.1.0ubuntu1
All of them are found:
idf#ubvm:$ whereis python
python: /usr/bin/python3.6m /usr/bin/python /usr/bin/python3.6m-config /usr/bin/python3.6-config /usr/bin/python2.7-config /usr/bin/python3.5 /usr/bin/python3.6 /usr/bin/python3.5m /usr/bin/python2.7 /usr/lib/python3.5 /usr/lib/python3.6 /usr/lib/python3.7 /usr/lib/python2.7 /etc/python /etc/python3.5 /etc/python3.6 /etc/python2.7 /usr/local/lib/python3.5 /usr/local/lib/python3.6 /usr/local/lib/python2.7 /usr/include/python3.6m /usr/include/python3.6 /usr/include/python2.7 /usr/share/python /usr/share/man/man1/python.1.gz
When linking a program, I get this error:
/usr/bin/ld: cannot find -lboost_python-py35
/usr/bin/ld: cannot find -lpython3.5m
So I am trying to build boost 1.69 from source, to support python 3.5.
ls /usr/bin/python*
/usr/bin/python /usr/bin/python2-config /usr/bin/python3.6 /usr/bin/python3-config
/usr/bin/python2 /usr/bin/python3 /usr/bin/python3.6-config /usr/bin/python3m
/usr/bin/python2.7 /usr/bin/python3.5 /usr/bin/python3.6m /usr/bin/python3m-config
/usr/bin/python2.7-config /usr/bin/python3.5m /usr/bin/python3.6m-config /usr/bin/python-config
When I run bootstrap, it is detecting python 2.7
idf#ubvm:~/Downloads/boost_1_69_0$ ./bootstrap.sh
Building Boost.Build engine with toolset gcc... tools/build/src/engine/bin.linuxx86_64/b2
Detecting Python version... 2.7
Detecting Python root... /usr
Unicode/ICU support for Boost.Regex?... /usr
Generating Boost.Build configuration in project-config.jam...
Bootstrapping is done. To build, run:
./b2
I then did a locate after installing ./b2 install:
idf#ubvm:$ locate libboost_python
/usr/lib/x86_64-linux-gnu/libboost_python-py27.a
/usr/lib/x86_64-linux-gnu/libboost_python-py27.so
/usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.65.1
/usr/lib/x86_64-linux-gnu/libboost_python-py36.a
/usr/lib/x86_64-linux-gnu/libboost_python-py36.so
/usr/lib/x86_64-linux-gnu/libboost_python.a
/usr/lib/x86_64-linux-gnu/libboost_python.so
/usr/lib/x86_64-linux-gnu/libboost_python3-py36.a
/usr/lib/x86_64-linux-gnu/libboost_python3-py36.so
/usr/lib/x86_64-linux-gnu/libboost_python3-py36.so.1.65.1
/usr/lib/x86_64-linux-gnu/libboost_python3.a
/usr/lib/x86_64-linux-gnu/libboost_python3.so
How do I tell the system to also build the python 3.5(m) libraries as well as the 2.7?

Can't install Ta-Lib with pip in Ubuntu 18.04

I need to install the TA-Lib library on python. Where I run the following:
pip install TA-Lib --user
I get this error code:
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-52h2r7l4/TA-Lib/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-meoq431k/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-install-52h2r7l4/TA-Lib/
I have also tried:
pip3 install TA-Lib
when I run:
python --version
I get:
Python 2.7.15rc1
Then I run:
python3 --version
I get:
Python 3.6.7
I can't understand. I have Ubuntu 18.04. Before I have Anaconda, then delete it (hope I delete it correctly) And then install Python 2.7 because I wanted to use Zipline to backtest some strategies, but I cannot use TA-Lib.
Hope someone know the problem, thank you!
I've downloaded TA-Lib-0.4.17.tar.gz that pip3 gets automatically. Opened it - there is no TA-Lib, only wrapper for it. According to its README.md
Dependencies
To use TA-Lib for python, you need to have the TA-Lib already installed. You should probably follow their installation directions for your
platform, but some suggestions are included below for reference.
Mac OS X
$ brew install ta-lib
Windows
Download ta-lib-0.4.0-msvc.zip and unzip to C:\ta-lib
This is a 32-bit release. If you want to use 64-bit Python, you will need to build a 64-bit version of the library.
Some unofficial (and unsupported) instructions for building on 64-bit Windows 10, here for reference:
Download and Unzip ta-lib-0.4.0-msvc.zip
Move the Unzipped Folder ta-lib to C:\
Download and Install Visual Studio Community 2015
Remember to Select [Visual C++] Feature
Build TA-Lib Library
From Windows Start Menu, Start [VS2015 x64 Native Tools Command Prompt]
Move to C:\ta-lib\c\make\cdr\win32\msvc
Build the Library nmake
Linux
Download ta-lib-0.4.0-src.tar.gz and:
$ untar and cd $ ./configure --prefix=/usr $ make $ sudo make install
If you build TA-Lib using make -jX it will fail but that’s OK! Simply rerun make -jX followed by [sudo] make install.
ta-lib depends on their C implementation you have to install it before installing the python version.

Failed to install tesserocr for Tesseract v4 - MacOS

I'm trying to pip install tesserocr but encountering the below error.
I've tried a few different ways to install suggested on its doc, all of which with no avail.
At this point I'm certain the issue is not related to this package (since my friend installed it on the his Mac with no problems, I also installed on a Ubuntu VM w/o issue).
The error seems to be c++ library since it cannot find headers or in Tesseract-OCR's source code (?), however before the error line it successfully finds .
I also have pytesseract installed w/o issue.
I'm hoping somebody here can help debug what's causing this issue.
My tesseract (installed through brew) version is:
tesseract 4.0.0
leptonica-1.76.0
libjpeg 9c : libpng 1.6.35 : libtiff 4.0.9 : zlib 1.2.11
Thanks and let me know what other info you might need.
Failed building wheel for tesserocr
Running setup.py clean for tesserocr
Failed to build tesserocr
Installing collected packages: tesserocr
Running setup.py install for tesserocr ... error
Complete output from command /Users/charlieyou/miniconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/2h/ty244jbd1vd3d1l0m4k3_g980000gn/T/pip-install-wgh41bv0/tesserocr/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/2h/ty244jbd1vd3d1l0m4k3_g980000gn/T/pip-record-0grp17wc/install-record.txt --single-version-externally-managed --compile:
pkg-config failed to find tesseract/lept libraries: b"Package tesseract was not found in the pkg-config search path.\nPerhaps you should add the directory containing `tesseract.pc'\nto the PKG_CONFIG_PATH environment variable\nNo package 'tesseract' found\n"
Supporting tesseract v4.0.0
Building with configs: {'libraries': ['tesseract', 'lept'], 'cython_compile_time_env': {'TESSERACT_VERSION': 262144}}
running install
running build
running build_ext
building 'tesserocr' extension
creating build
creating build/temp.macosx-10.7-x86_64-3.6
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/charlieyou/miniconda3/include -arch x86_64 -I/Users/charlieyou/miniconda3/include -arch x86_64 -I/usr/local/include -I/Users/charlieyou/miniconda3/include/python3.6m -c tesserocr.cpp -o build/temp.macosx-10.7-x86_64-3.6/tesserocr.o -std=c++11 -DUSE_STD_NAMESPACE
warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
In file included from tesserocr.cpp:603:
**/usr/local/include/tesseract/unichar.h:24:10: fatal error: 'cstring' file not found
#include <cstring>**
^~~~~~~~~
1 warning and 1 error generated.
error: command 'gcc' failed with exit status 1
I had the same problem on my mac,
You should try install the package with conda :
conda install -c mcs07 tesserocr
you can try : xcode-select --install
and I also can't install it , my error message is :
error: command '/usr/bin/clang' failed with exit status 1

"pip install scipy" failed in Travis CI python 3.7 env

I have problem to setup my project in Travis CI python 3.7 environment, although simply running with 'pip install scipy' in python 3.6 works fine. There lots of similar/same problems and solutions reported before [1], but answers does not work for me.
Can anyone help to explain why it works with python 3.6 [2], while failed with python 3.7 in Travis CI server ?
I finally tried with the following scripts, but it still does not work in Travis CI (python 3.7) env. Travis CI (python 3.6 and python 3.6 dev) still work fine.
python -m pip install --upgrade pip
pip install --upgrade pip setuptools wheel
sudo apt-get build-dep python-scipy
sudo apt-get install -qq python-scipy
pip install scipy
...
[1] https://github.com/travis-ci/travis-ci/issues/2890
[2] https://travis-ci.org/jerrygaoLondon/jgtextrank/jobs/323822420
Errors:
Building wheels for collected packages: scipy
Running setup.py bdist_wheel for scipy ... error
Complete output from command /home/travis/virtualenv/python3.7-dev/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-j7d10poq/scipy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmp2u1cz0lipip-wheel- --python-tag cp37:
lapack_opt_info:
lapack_mkl_info:
libraries mkl_rt not found in ['/home/travis/virtualenv/python3.7-dev/lib', '/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
NOT AVAILABLE
...
For more details of the error, please check out https://travis-ci.org/jerrygaoLondon/jgtextrank/jobs/323822422
There are no binary wheels yet for Python 3.7 (the list is on https://pypi.python.org/pypi/scipy) so pip downloads the source package for SciPy and attempts to compile it. This fails most of the time because you need a full development environment for Python and the assorted libraries (BLAS and LAPACK with development headers), see https://scipy.org/install.html and https://github.com/scipy/scipy/blob/master/INSTALL.rst.txt .
Your solutions:
Roll back to Python 3.6, which I would suggest.
Make sure to install the development libraries for Python 3.7 and the libraries (+ headers) for BLAS and LAPACK.

Resources