python : pandas install errors on container - python

I want to install pandas on docker image containing python. I used the code below to run a container:
docker run -p 8888:8888 -v /home/DATA/Project_NY/:/home/jovyan/work/Project_NY jupyter/scipy-notebook
I created a new notebook and then tried to install my requirements file doing pip install -r "requirements.txt" i got the error below and when I tried to pip install pandas inside that running container it works perfectly:
requirements.txt content
SQLAlchemy==1.2.2
pandas==0.25.0
docker==3.3.0
python-json-logger
sshtunnel==0.1.4
jupyter
jupytext==0.8.4
matplotlib
seaborn
psycopg2-binary
the error is
building 'pandas._libs.algos' extension
creating build/temp.linux-x86_64-3.9
creating build/temp.linux-x86_64-3.9/pandas
creating build/temp.linux-x86_64-3.9/pandas/_libs
gcc -pthread -B /opt/conda/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /opt/conda/include -fPIC -O2 -isystem /opt/conda/include -fPIC -DNPY_NO_DEPRECATED_API=0 -I./pandas/_libs -Ipandas/_libs/src/klib -Ipandas/_libs/src -I/opt/conda/lib/python3.9/site-packages/numpy/core/include -I/opt/conda/include/python3.9 -c pandas/_libs/algos.c -o build/temp.linux-x86_64-3.9/pandas/_libs/algos.o -Wno-unused-function
error: command 'gcc' failed: No such file or directory
----------------------------------------
ERROR: Failed building wheel for pandas

It seems like the pandas version you are trying to install needs a custom build for the System you're using as Dockercontainer.
You should get the same error if you run pip install pandas==0.25.0 inside the container.
Either use a different version of pandas or install gcc in the container ( e.g.: for alpine, inside Dockerfile CMD apk add --no-cache --virtual .build-deps gcc).
EDIT: I think the 'jupyter/scipy-notebook'-image uses conda, so maybe try:
docker run -p 8888:8888 -v /home/DATA/Project_NY/:/home/jovyan/work/Project_NY jupyter/scipy-notebook conda install gcc
the conda install gcc in the end is executed inside the container.

Related

Running QuantLib python on 'apple silicon' Macbook

I am trying to run Quantlib-Python on a Macbook with M1 processor (Big Sur v11.3) following https://www.quantlib.org/install/macosx-python.shtml. I have managed to install Quantlib 1.22 and Python 3.9.4 via homebrew:
Pouring quantlib--1.22.arm64_big_sur.bottle.tar.gz into "/opt/homebrew/Cellar/quantlib/1.22"
However when I then try to install Quantlib-Python through pip I get:
ERROR: Could not find a version that satisfies the requirement QuantLib (from versions: none)
ERROR: No matching distribution found for QuantLib
From this it seems that whilst Quantlib 1.22 is ready for arm-based OSX, QuantLib-Python isn't.
Then I am trying to install from a released version as per the above link:
tar xzf QuantLib-SWIG-1.22.tar.gz
cd QuantLib-SWIG-1.22/Python
export CXXFLAGS='-O2 -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.9'
export LDFLAGS='-stdlib=libc++ -mmacosx-version-min=10.9'
python setup.py build
But I get the following error:
cd QuantLib-SWIG-1.22/Python
export CXXFLAGS='-O2 -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.9'
export LDFLAGS='-stdlib=libc++ -mmacosx-version-min=10.9'
python setup.py build
running build
running build_py
running build_ext
building 'QuantLib._QuantLib' extension
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -DNDEBUG -I/Users/USER/coding/project1/include -I/Users/USER/.pyenv/versions/3.9.4/include/python3.9 -I/opt/homebrew/Cellar/quantlib/1.22/include -c QuantLib/quantlib_wrap.cpp -o build/temp.macosx-11.3-arm64-3.9/QuantLib/quantlib_wrap.o -Wno-unused -O2 -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.9
In file included from QuantLib/quantlib_wrap.cpp:4730:
In file included from /opt/homebrew/Cellar/quantlib/1.22/include/ql/version.hpp:28:
/opt/homebrew/Cellar/quantlib/1.22/include/ql/qldefines.hpp:38:10: fatal error: 'boost/config.hpp' file not found
#include <boost/config.hpp>
^~~~~~~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
I have tried quite a few workarounds for the boost issue, and looked over lots of other question/answers but yet to find a fix. Is it an issue with the flags? Has anyone had any luck getting QuantLib-Python to work on M1-based OSX?
Below worked for me on a MBP M1 Max:
brew install boost
brew install quantlib
download QuantLib-SWIG-1.24.tar
tar xzfv QuantLib-SWIG-1.24.tar
cd QuantLib-SWIG-1.24/Python
export CXXFLAGS='-O2 -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.9 -I/opt/homebrew/Cellar/boost/1.76.0/include'
export LDFLAGS='-stdlib=libc++ -mmacosx-version-min=10.9 -L/opt/homebrew/Cellar/boost/1.76.0/lib'
python setup.py build
python setup.py bdist_wheel
cd dist
pip install QuantLib-1.24-cp310-cp310-macosx_11_0_arm64.whl

twisted-iocpsupport error when using pip on ubuntu / debian io.h missing

Receiving error:
Building wheel for twisted-iocpsupport (PEP 517): started
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 /tmp/tmpv8s6qz76 build_wheel /tmp/tmp9l8hgcva
cwd: /tmp/pip-install-qsr4j4x_/twisted-iocpsupport
Complete output (13 lines):
running bdist_wheel
running build
running build_ext
building 'twisted_iocpsupport.iocpsupport' extension
creating build
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/twisted_iocpsupport
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Itwisted_iocpsupport -I/usr/include/pyth
on3.8 -c twisted_iocpsupport/iocpsupport.c -o build/temp.linux-x86_64-3.8/twisted_iocpsupport/iocpsupport.o
twisted_iocpsupport/iocpsupport.c:631:10: fatal error: io.h: No such file or directory
631 | #include "io.h"
| ^~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for twisted-iocpsupport
Building wheel for twisted-iocpsupport (PEP 517): finished with status 'error'
with
channels==3.0.3
daphne==3.0.1
Twisted==21.2.0
twisted-iocpsupport==1.0.1
In a docker environment:
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get -y install python3 python3-pip
WORKDIR /usr/src/app
# Copy requirements
COPY requirements.txt ./
RUN pip3 install -r requirements.txt
also no chance on python:3.8 or debian:10.8
including python-dev in the apt command also does not help.
Not sure what type of io.h file is required and how to obtain it. On google nothing really pops up and in the 2500 open issues on twistedmatrix, I cannot find anything related to this. The release seems to be from today 1st March 2021. Same error on 1.0.0
twisted-iocpsupport is a package providing bindings to the Windows "I/O Completion Ports" APIs. These are Windows-only APIs.
You cannot use this package on Debian. Fortunately, you also don't need to as you have access to a good Linux-based non-blocking I/O system - epoll - which is supported in Twisted without the use of any additional packages.
if you are working on Amazon Linux Platform 2 then also it is not needed that twisted package dependencies it will throw error if you have used it in your dependencies as per screenshot given below .
enter image description here

No OCR tool found in python

I have downloaded Mayan EDMS-Electronic Document Management System from GitHub and I configured project using Django server. I had added the required libraries based on requirement. Now the project runs with error
ocr.exceptions.OCRError: No OCR tool found
When I searched this error, I found Pyocr looks for the OCR tools (Tesseract, Cuneiform, etc) installed on your system and just tells you what it has found.
Then I tried to install tesseract using the command -->pip install tesseract-ocr.
I got this error
Requirement already satisfied: cython in ./venv2/lib/python2.7/site-packages (from tesseract-ocr) (0.28.4)
running bdist_wheel
running build
running build_py
file tesseract_ocr.py (for module tesseract_ocr) not found
file tesseract_ocr.py (for module tesseract_ocr) not found
running build_ext
building 'tesseract_ocr' extension
creating build
creating build/temp.linux-x86_64-2.7
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-l1RrwO/python2.7-2.7.14=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c tesseract_ocr.cpp -o build/temp.linux-x86_64-2.7/tesseract_ocr.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
tesseract_ocr.cpp:600:10: fatal error: leptonica/allheaders.h: No such file or directory
#include "leptonica/allheaders.h"
please help me to solve this issue. Thanks in advance.
Tesseract is installed on the OS using the apt-get command. The command you are using (PIP) is for installing Python packages, that is the reason for the error.
For reference: http://docs.mayan-edms.com/en/stable/topics/deploying.html#deploying
If using a Debian or Ubuntu based Linux distribution, get the executable requirements using:
sudo apt-get install g++ gcc ghostscript gnupg1 graphviz libjpeg-dev libmagic1 \
libpq-dev libpng-dev libreoffice libtiff-dev poppler-utils postgresql \
python-dev python-pip python-virtualenv redis-server sane-utils supervisor \
tesseract-ocr zlib1g-dev -y

Error installing mply library. Fatal error: gsl/gsl_sf.h: No such file or directory

I'm trying to install the latest version of mply (3.5.0) on xubuntu (ubuntu 17.10):
download the .tar.gz
Unzipped it
python setup.py build. Here I get the error displayed below.
also tried directly python setup.py install. same error.
tried installing gsl library by downloading the latest version, and following all the steps in https://coral.ise.lehigh.edu/jild13/2016/07/11/hello/. I have it installed in /home/gsl
still the same error
tried various other installations (sudo apt-get install libgsl0ldbl, sudo apt-get install libgs123, sudo apt-get install libgsl0-dev). Nothing works.
tried copying the folder /home/gsl/include/gsl inside the mply-3.5.0/mply/gsl folder . this slightly changes something, because now I get fatal error: gsl/gsl_sf_result.h: No such file or directory (So it finds gsl_sf.h, but not gsl_sf_result.h (both these files are present inside the /gsl/include/gsl folder).
tried with
python setup.py build_ext --include-dirs=/home/gls/include/gls
still nothing
tried to copy the /home/gsl/include/gsl folder inside my /usr/local/include:
cp -R /home/gsl/include/gsl /usr/local/include/gsl
still nothing.
Help!
Error message:
gcc -pthread -B /home/lorenzo/anaconda3/compiler_compat
-Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall
-Wstrict-prototypes -fPIC -I/home/lorenzo/anaconda3/include/python3.6m
-I/home/lorenzo/anaconda3/lib/python3.6/site-packages/numpy/core/include
-I/home/lorenzo/anaconda3/include/python3.6m -c mlpy/gsl/gsl.c
-o build/temp.linux-x86_64-3.6/mlpy/gsl/gsl.o
mlpy/gsl/gsl.c:223:10: fatal error: gsl/gsl_sf.h: No such file or directory
#include "gsl/gsl_sf.h"
SOLVED by re-installing gsl library using conda:
conda install gsl

I've got a CPython C++ module with C++11 code, but I can't seem to build on travis-ci

This project work fine on my local Ubuntu 12.04 and Mac OSX 10.10 (with fink python) machines. I can't seem to figure out how to configure the .travis.yml to get the .cpp files to build with g++-4.8 (4.9 or 5.x) would be fine too.
Project: https://github.com/schwehr/libais
My most recent failed attempt:
language: python
python:
- "2.7"
- "3.4"
before_install:
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get update -qq
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
install:
- sudo apt-get install -qq gcc-4.8 g++-4.8
- python setup.py install
script:
- python setup.py test
Gives:
gcc -pthread -fno-strict-aliasing -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/opt/python/2.7.9/include/python2.7 -c src/libais/ais_py.cpp -o build/temp.linux-x86_64-2.7/src/libais/ais_py.o -std=c++11
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
cc1plus: error: unrecognized command line option ‘-std=c++11’
The key portion of my setup.py:
EXTRA_COMPILE_ARGS = []
if sys.platform in ('darwin', 'linux', 'linux2'):
EXTRA_COMPILE_ARGS = ['-std=c++11']
AIS_MODULE = Extension(
'_ais',
extra_compile_args=EXTRA_COMPILE_ARGS,
Thanks Dominic. I tried printing things and that was helpful. That got me thinking that I could just get explicit and force python to use the correct compiler. That makes it easier to see what is happening.
install:
- sudo apt-get install -qq gcc-4.8 g++-4.8
- CC=g++-4.8 python setup.py install
Which works.

Categories

Resources