I am building a Django implementation with docker. I'm using the python container as base, but in my requirements file I have the below:-
boto==2.43.0
boto3==1.4.4
botocore==1.5.55
ciscoconfparse==1.2.47
Django==1.11.4
django-appconf==1.0.2
django-auth-ldap==1.2.10
django-dbtemplates==2.0
django-debug-toolbar==1.7
easy-thumbnails==2.3
easysnmp==0.2.4
ipaddress==1.0.18
Jinja2==2.9.5
mysqlclient-1.3.10
netmiko==1.2.8
O365==0.9.5
orionsdk==0.0.6
paramiko==2.1.2
python-dateutil==2.6.0
python-ldap==2.4.32
pytz==2016.10
pyOpenSSL==17.2.0
sqlparse==0.2.3
urllib3==1.21.1
joblib==0.11
some of these have dependencies that fail when using the python container on its own, for example...
#include <net-snmp/net-snmp-config.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed building wheel for easysnmp
...
...
#include "lber.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed building wheel for pyldap
...
...
In file included from Modules/LDAPObject.c:9:0:
Modules/errors.h:8:18: fatal error: lber.h: No such file or directory
#include "lber.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-aufmftap/pyldap/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-fjdz1te2-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-aufmftap/pyldap/
how do I install OS dependencies for python modules? within a container? what os does the python container run on for me to get the right dependencies?
Thanks
Assuming you are using the python:3.6 image which is currently the latest, you need to install some additional libraries.
Dockerfile example (the pip libraries are in the requirements.txt file):
FROM python:3.6
RUN apt-get update -y \
&& apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev libsnmp-dev
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
Related question: I can't install python-ldap
I had to update the run command to get it to work
RUN apt-get update -y
RUN apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev libsnmp-dev -y
Related
I would greatly appreciate help in tackling a problem that drives me crazy (I do need Ubuntu 18.04 and python 3). I did try using different scenarios, but everything fails when installing PyPI package isal on Ubuntu 18.04:
FROM ubuntu:18.04
RUN apt update -y && apt upgrade -y
RUN apt install -y python3 python3-pip
RUN pip3 install isal
docker build . fails with:
Step 3/3 : RUN pip3 install isal
---> Running in 71a47c31d97c
Collecting isal
Downloading https://files.pythonhosted.org/packages/d6/72/b997fd8ba95a0820edcd5da268505705a5518fd860d64bf28a7c1c343a3a/isal-0.11.0.tar.gz (680kB)
Building wheels for collected packages: isal
Running setup.py bdist_wheel for isal: started
Running setup.py bdist_wheel for isal: finished with status 'error'
....
running build_ext
/tmp/tmpk3o08f96/autogen.sh: 3: /tmp/tmpk3o08f96/autogen.sh: autoreconf: not found
error: [Errno 2] No such file or directory: '/tmp/tmpk3o08f96/configure': '/tmp/tmpk3o08f96/configure'
----------------------------------------
Failed building wheel for isal
Running setup.py clean for isal
Failed to build isal
Installing collected packages: isal
Running setup.py install for isal: started
Running setup.py install for isal: finished with status 'error'
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-qa68yevk/isal/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-8qioc11y-record/install-record.txt --single-version-externally-managed --compile:
/usr/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
....
running build_ext
/tmp/tmpnfxsy9ug/autogen.sh: 3: /tmp/tmpnfxsy9ug/autogen.sh: autoreconf: not found
error: [Errno 2] No such file or directory: '/tmp/tmpnfxsy9ug/configure': '/tmp/tmpnfxsy9ug/configure'
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-qa68yevk/isal/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-8qioc11y-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-qa68yevk/isal/
The command '/bin/sh -c pip3 install isal' returned a non-zero code: 1
while FROM ubuntu:20.04 everything works fine
pip also fails:
FROM ubuntu:18.04
RUN apt update -y && apt upgrade -y \
&& apt install -y python python-pip
RUN pip install isal
Step 3/3 : RUN pip install isal
---> Running in 6e157d7d965a
Collecting isal
Could not find a version that satisfies the requirement isal (from versions: )
No matching distribution found for isal
The command '/bin/sh -c pip install isal' returned a non-zero code: 1
you can try apt install autoconf to resolve autoreconf: not found
The project was working perfectly until recently when I created a model for my database and tried to pip install requirement.txt. I have done everything I know including modifying my settings.py to add the missing library, reinstalling django and psycopg2, all to no avail. Here's my requirement.txt:
tweepy==3.8.0
django
gunicorn
django-heroku
The error i'm getting:
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/Users/apple/Downloads/font_text/python-getting-started/getting-started/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/tn/843ff_ns4j5ddf0fyc998v6c0000gn/T/pip-install-phi9wroh/psycopg2/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/tn/843ff_ns4j5ddf0fyc998v6c0000gn/T/pip-record-sc3y24vo/install-record.txt --single-version-externally-managed --compile --install-headers /Users/apple/###/###/PROJECTFOLDER/getting-started/include/site/python3.7/psycopg2" failed with error code 1 in /private/var/folders/tn/843ff_ns4j5ddf0fyc998v6c0000gn/T/pip-install-phi9wroh/psycopg2/
Based on the error message, you need to install the openssl-devel package on your system.
After long hours of searching and experimenting, I finally was able to solve the problem. But I'm still investigating on what really could have caused the error. Anyways, here's what fixed it
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
pip install psycopg2
I found it here: error installing psycopg2, library not found for -lssl
You need to reinstall gcc , gcc-c++ and dependencies.
For python 2.7
$ sudo yum -y install gcc gcc-c++ kernel-devel
$ sudo yum -y install python-devel libxslt-devel libffi-devel openssl-devel
$ pip install "your python packet"
For python 3.4
$ sudo apt-get install python3-dev
$ pip install "your python packet"
Hope this will help.
Currently building the image:
FROM python:3.7-slim-stretch
WORKDIR /root/forstack-host
COPY requirements.txt /root/requirements.txt
RUN apt-get update && apt-get install -y libgomp1 gcc
RUN apt-get install -y libpq-dev
RUN apt-get install net-tools
RUN apt-get install -y libhdf5-serial-dev hdf5-tools
RUN python3 -m pip install --no-cache-dir -U pip && \
python3 -m pip install --no-cache-dir -r /root/requirements.txt
When installing tables=3.4.4 I get the error
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-91revz2s/tables/setup.py'"'"'; __file__='"'"'/tmp/pip-install-91revz2s/tables/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-91revz2s/tables/pip-egg-info
cwd: /tmp/pip-install-91revz2s/tables/
Complete output (12 lines):
/tmp/H5close9pyniq85.c: In function ‘main’:
/tmp/H5close9pyniq85.c:2:5: warning: implicit declaration of function ‘H5close’ [-Wimplicit-function-declaration]
H5close();
^~~~~~~
/usr/bin/ld: cannot find -lhdf5
collect2: error: ld returned 1 exit status
* Using Python 3.7.5 (default, Oct 19 2019, 00:03:48)
* USE_PKGCONFIG: True
.. ERROR:: Could not find a local HDF5 installation.
You may need to explicitly state where your local HDF5 headers and
library can be found by setting the ``HDF5_DIR`` environment
variable or by using the ``--hdf5`` command-line option.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Using RUN apt-get install -y libhdf5-serial-dev hdf5-tools doesn't seem to fix this error and I can't seem to set the HDF5_DIR env. Is there a working 3.7 image with a fix for this hdf5 issue?
you may try add this ARG to your Dockerfile before installing:
ARG HDF5_DIR=PATH_TO_YOUR_HDF5 # normally should be in /usr/local or /opt/local
you may also need to install build-dep
My commands for installing rocksdb were:
apt-get install build-essential libsnappy-dev zlib1g-dev libbz2-dev libgflags-dev
git clone https://github.com/facebook/rocksdb.git
cd rocksdb
mkdir build && cd build
cmake ..
make
make install-shared INSTALL_PATH=/usr
cd ..
make install-shared INSTALL_PATH=/usr
apt-get install python-virtualenv python-dev librocksdb-dev
pip3 install python-rocksdb
I have also tried to install python-rocksdb using virtualenv.
Regardless of types of attempts, I get the following error:
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/home/aviral/dev/rocksdb/venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-5kagbe5y/python-rocksdb/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-n3jza3pc/install-record.txt --single-version-externally-managed --compile --install-headers /home/aviral/dev/rocksdb/venv/include/site/python3.6/python-rocksdb" failed with error code 1 in /tmp/pip-install-5kagbe5y/python-rocksdb/
The full error is here.
I just ran into this yesterday. It looks like there was just a PR into the facebook repo that removed store_index_in_file.
I got it working by checking out the previous tag and building from there.
Try cd rocksdb && git checkout tags/v5.17.2 && make install-shared INSTALL_PATH=/usr instead (adding the command to checkout the tag).
I'd previously used Anaconda to handle python, but I'm and start working with virtual environments.
I set up virtualenv and virtualenvwrapper, and have been trying to add modules, specifically scrapy and lxml, for a project I want to try.
Each time I pip install, I hit an error.
For scrapy:
File "/home/philip/Envs/venv/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1003, in run_setup
raise DistutilsError("Setup script exited with %s" % (v.args[0],))
distutils.errors.DistutilsError: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
---------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /home/philip/Envs/venv/build/cryptography
Storing debug log for failure in /home/philip/.pip/pip.log
For lxml:
In file included from src/lxml/lxml.etree.c:346:0:
/home/philip/Envs/venv/build/lxml/src/lxml/includes/etree_defs.h:9:31: fatal error: libxml/xmlversion.h: No such file or directory
include "libxml/xmlversion.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Cleaning up... Command /home/philip/Envs/venv/bin/python -c "import setuptools, tokenize;__file__='/home/philip/Envs/venv/build/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-zIsPdl-record/install-record.txt
--single-version-externally-managed --compile --install-headers /home/philip/Envs/venv/include/site/python2.7 failed with error code 1 in /home/philip/Envs/venv/build/lxml Storing debug log for failure in /home/philip/.pip/pip.log
I tried to install it following scrapy's documentation, but scrapy was still not listed when I called for python's installed modules.
Any ideas? Thanks--really appreciate it!
I'm on Ubuntu 13.10 if it matters. Other modules I've tried have installed fine (though I've only gone for a handful).
I had the same problem in Ubuntu 14.04. I've solved it with the instructions of the page linked by #jdigital and the openssl-dev library pointed by #user3115915. Just to help others:
sudo apt-get install libxslt1-dev libxslt1.1 libxml2-dev libxml2 libssl-dev
sudo pip install scrapy
In my case, I solve the problem installing all the libraries that Manuel mention plus the extra library: libffi-dev
https://askubuntu.com/questions/499714/error-installing-scrapy-in-virtualenv-using-pip
Updated from #Mario C. and #Manuel,
Here is commands:
sudo apt-get install libxslt1-dev libxslt1.1 libxml2-dev libxml2 libssl-dev libffi-dev
sudo pip install scrapy