无法在docker中安装nmslib

问题描述 投票:1回答:1

我无法在docker中使用nmslib安装pip

这是我的Dockerfile:

FROM continuumio/anaconda3:4.4.0
MAINTAINER UNP, https://unp.education
EXPOSE 8000
RUN apt-get update && apt-get install -y apache2 \
    apache2-dev \
    emacs \
 && apt-get clean \
 && apt-get autoremove \
 && rm -rf /var/lib/apt/lists/*
WORKDIR /var/www/devise-api/
COPY ./devise-api.wsgi /var/www/devise-api/devise-api.wsgi
COPY ./devise-api /var/www/devise-api/
RUN pip install -r requirements.txt
RUN /opt/conda/bin/mod_wsgi-express install-module
RUN mod_wsgi-express setup-server devise-api.wsgi --port=8000 \
    --user www-data --group www-data \
    --server-root=/etc/mod_wsgi-express-80
CMD /etc/mod_wsgi-express-80/apachectl start -D FOREGROUND

目前requirements.txt只包含nmslib这个词

这是运行sudo docker build -t devise-api .时得到的输出:

Sending build context to Docker daemon  306.2MB
Step 1/11 : FROM continuumio/anaconda3:4.4.0
 ---> 795ad88c47ff
Step 2/11 : MAINTAINER UNP, https://unp.education
 ---> Using cache
 ---> cd5b1f7e6188
Step 3/11 : EXPOSE 8000
 ---> Using cache
 ---> 21ad868f0823
Step 4/11 : RUN apt-get update && apt-get install -y apache2     apache2-dev     emacs  && apt-get clean  && apt-get autoremove  && rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> ebfc7c30b394
Step 5/11 : WORKDIR /var/www/devise-api/
 ---> Using cache
 ---> 8228e4b4d4fd
Step 6/11 : COPY ./devise-api.wsgi /var/www/devise-api/devise-api.wsgi
 ---> Using cache
 ---> c8cf5cfcf7dc
Step 7/11 : COPY ./devise-api /var/www/devise-api/
 ---> Using cache
 ---> 856e67f0b1de
Step 8/11 : RUN pip install -r requirements.txt
 ---> Running in 7260901af476
Collecting nmslib (from -r requirements.txt (line 1))
  Downloading https://files.pythonhosted.org/packages/e1/95/1f7c90d682b79398c5ee3f9296be8d2640fa41de24226bcf5473c801ada6/nmslib-1.7.3.6.tar.gz (255kB)
Collecting pybind11>=2.0 (from nmslib->-r requirements.txt (line 1))
  Downloading https://files.pythonhosted.org/packages/f2/7c/e71995e59e108799800cb0fce6c4b4927914d7eada0723dd20bae3b51786/pybind11-2.2.4-py2.py3-none-any.whl (145kB)
Requirement already satisfied: numpy in /opt/conda/lib/python3.6/site-packages (from nmslib->-r requirements.txt (line 1))
Building wheels for collected packages: nmslib
  Running setup.py bdist_wheel for nmslib: started
  Running setup.py bdist_wheel for nmslib: finished with status 'error'
  Complete output from command /opt/conda/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-4qfop8hr/nmslib/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/tmpl9tnakclpip-wheel- --python-tag cp36:
  running bdist_wheel
  running build
  running build_ext
  creating tmp
  gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/opt/conda/include/python3.6m -c /tmp/tmp2pnwck3x.cpp -o tmp/tmp2pnwck3x.o -std=c++14
  cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
  gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/opt/conda/include/python3.6m -c /tmp/tmp5ktoxd0l.cpp -o tmp/tmp5ktoxd0l.o -fvisibility=hidden
  cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
  building 'nmslib' extension
  creating build
  creating build/temp.linux-x86_64-3.6
  creating build/temp.linux-x86_64-3.6/nmslib
  creating build/temp.linux-x86_64-3.6/nmslib/similarity_search
  creating build/temp.linux-x86_64-3.6/nmslib/similarity_search/src
  creating build/temp.linux-x86_64-3.6/nmslib/similarity_search/src/space
  creating build/temp.linux-x86_64-3.6/nmslib/similarity_search/src/method
  gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I./nmslib/similarity_search/include -I/opt/conda/include/python3.6m -I/root/.local/include/python3.6m -I/opt/conda/lib/python3.6/site-packages/numpy/core/include -I/opt/conda/include/python3.6m -c nmslib.cc -o build/temp.linux-x86_64-3.6/nmslib.o -O3 -march=native -fopenmp -DVERSION_INFO="1.7.3.6" -std=c++14 -fvisibility=hidden
  cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
  nmslib.cc:16:31: fatal error: pybind11/pybind11.h: No such file or directory
   #include <pybind11/pybind11.h>
                                 ^
  compilation terminated.
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for nmslib
  Running setup.py clean for nmslib
Failed to build nmslib
Installing collected packages: pybind11, nmslib
  Running setup.py install for nmslib: started

然后它永远保持这样。有谁知道我可以尝试解决这个问题?

非常感谢你提前!

最好的祝福

F

python docker gcc pip pybind11
1个回答
1
投票

我刚刚面临同样的问题并通过在安装RUN之前添加nmslib步骤来修复它:

RUN pip install pip==9.0.3 pybind11

见:https://github.com/nmslib/nmslib/issues/307#issuecomment-384113900。希望这对你的情况也有帮助:-)

© www.soinside.com 2019 - 2024. All rights reserved.