Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/154.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python docker映像上安装simstring(SWIG) 我试图在Python DoCKER映像(Python:Python:Python:3.7)上安装C++包_Python_C++_Docker_G++_Swig - Fatal编程技术网

在python docker映像上安装simstring(SWIG) 我试图在Python DoCKER映像(Python:Python:Python:3.7)上安装C++包

在python docker映像上安装simstring(SWIG) 我试图在Python DoCKER映像(Python:Python:Python:3.7)上安装C++包,python,c++,docker,g++,swig,Python,C++,Docker,G++,Swig,我所采取的步骤是,按照回购协议/我所能收集到的信息的指示: docker run -it python:latest /bin/bash autoconf -i apt-get install swig git clone https://github.com/chokkan/simstring.git cd simstring ./configure cd swig/python ./prepare.sh --swig python setup build_ext 这就是我得到两个错误的地方

我所采取的步骤是,按照回购协议/我所能收集到的信息的指示:

docker run -it python:latest /bin/bash
autoconf -i
apt-get install swig
git clone https://github.com/chokkan/simstring.git
cd simstring
./configure
cd swig/python
./prepare.sh --swig
python setup build_ext
这就是我得到两个错误的地方:

/usr/bin/ld: cannot find -liconv
/usr/bin/ld: cannot find -lpython
不知何故,我需要传递它们的位置来构建_ext,但我找不到要链接的文件,也找不到如何链接它们。有什么想法吗?(遗憾的是,Simstring纯python包不是一个选项。)

更新 根据下面的excellend答案构建docker图像后,我进入下一个路障,看起来iconv仍然没有找到。顺便说一句,在3.7 python中,这甚至无法构建。但是3.8是可以的

docker run -it simstring
Python 3.8.0 (default, Oct 17 2019, 05:36:36)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import simstring
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/simstring.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 657, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 556, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1101, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: libiconv.so.2: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/simstring.py", line 17, in <module>
    _simstring = swig_import_helper()
  File "/usr/local/lib/python3.8/site-packages/simstring.py", line 16, in swig_import_helper
    return importlib.import_module('_simstring')
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: libiconv.so.2: cannot open shared object file: No such file or directory
docker运行-it simstring
Python 3.8.0(默认值,2019年10月17日,05:36:36)
linux上的[GCC 8.3.0]
有关详细信息,请键入“帮助”、“版权”、“信用证”或“许可证”。
>>>导入模拟字符串
回溯(最近一次呼叫最后一次):
swig\u import\u helper中的文件“/usr/local/lib/python3.8/site packages/simstring.py”,第14行
返回导入lib.import\u模块(mname)
导入模块中的文件“/usr/local/lib/python3.8/importlib/_init__.py”,第127行
return _bootstrap._gcd_import(名称[级别:],包,级别)
文件“”,第1014行,在\u gcd\u导入中
文件“”,第991行,在“查找”和“加载”中
文件“”,第975行,在“查找”和“加载”中解锁
文件“”,第657行,已加载
文件“”,第556行,位于\u规范的模块\u中
文件“”,第1101行,在创建_模块中
文件“”,第219行,在“调用”中,删除了“帧”
ImportError:libiconv.so.2:无法打开共享对象文件:没有这样的文件或目录
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“/usr/local/lib/python3.8/site packages/simstring.py”,第17行,在
_simstring=swig\u import\u helper()
swig\u import\u helper中的文件“/usr/local/lib/python3.8/site packages/simstring.py”,第16行
返回importlib.import\u模块(“模拟字符串”)
导入模块中的文件“/usr/local/lib/python3.8/importlib/_init__.py”,第127行
return _bootstrap._gcd_import(名称[级别:],包,级别)
ImportError:libiconv.so.2:无法打开共享对象文件:没有这样的文件或目录

您可以使用此Dockerfile:

FROM python:3.8
RUN wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz \
    && tar -xvzf libiconv-1.16.tar.gz \
    && cd libiconv-1.16 \
    && ./configure --prefix=/usr/local/lib \
    && make \
    && make install \
    && cd /usr/local/lib \
    && ln -s lib/libiconv.so libiconv.so \
    && ln -s libpython3.8.so.1.0 libpython.so \
    && ln -s lib/libiconv.so.2 libiconv.so.2

RUN apt-get update && apt-get install -y swig vim
RUN git clone https://github.com/chokkan/simstring.git
RUN cd simstring \
    && autoreconf -i \
    && ./configure \
    && cd swig/python \
    && ./prepare.sh --swig \
    && python setup.py build_ext \
    && python setup.py install
最后结果:

byte-compiling /usr/local/lib/python3.8/site-packages/simstring.py to simstring.cpython-38.pyc
running install_egg_info
Writing /usr/local/lib/python3.8/site-packages/simstring-1.1-py3.8.egg-info

这是一个很好的开始,但根据更新的问题,我仍然得到了错误。它使图像正常。(末尾是CMD python和
docker build-t simstring.
),但由于找不到
libiconv.so.2
,因此使用该包失败。请参阅更新,它现在可以工作了,请按原样复制文件注意:如果您想使用python3.7,那么这一行'ln-s libpython3.8.so.1.0 libpython.so`是不同的,因为正在使用
libpython3.8
,需要使用python:3.8中的
,否则会引发错误。如果有人想知道,与simstring pure相比,10k条目的列表的加速比约为20倍。