pip 从 docker 容器内安装 pymssql

Posted

技术标签:

【中文标题】pip 从 docker 容器内安装 pymssql【英文标题】:pip install pymssql from inside docker container 【发布时间】:2016-12-09 23:30:30 【问题描述】:

我的 docker 容器使用的是 centos6.6。 pip install pymssql 失败:

Step 15 : RUN pip install pymssql
 ---> Running in c6a17c43790d
Collecting pymssql
  Downloading http://piprepo-au/piprepo/pymssql/pymssql-2.1.1.zip (2.3MB)
Installing collected packages: pymssql
  Running setup.py install for pymssql: started
    Running setup.py install for pymssql: finished with status 'error'
    Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-6Tr3gO/pymssql/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-DZY29I-record/install-record.txt --single-version-externally-managed --compile:
setup.py: platform.system() => 'Linux'
setup.py: platform.architecture() => ('64bit', '')
setup.py: platform.linux_distribution() => ('CentOS', '6.6', 'Final')
setup.py: platform.libc_ver() => ('glibc', '2.3')
setup.py: Not using bundled FreeTDS
setup.py: include_dirs = ['/usr/local/include']
setup.py: library_dirs = ['/usr/local/lib']
running install
running build
running build_ext
cythoning _mssql.pyx to _mssql.c

Error compiling Cython file:
------------------------------------------------------------
...
            return uuid.UUID(bytes_le=(<char *>data)[:length])

        else:
            return (<char *>data)[:length]

    cdef int convert_python_value(self, object value, BYTE **dbValue,
        ^
------------------------------------------------------------

_mssql.pyx:821:9: Signature not compatible with previous declaration

Error compiling Cython file:
------------------------------------------------------------
...
    cdef object msghandler

    cpdef cancel(self)
    cdef void clear_metadata(self)
    cdef object convert_db_value(self, BYTE *, int, int)
    cdef int convert_python_value(self, object value, BYTE **, int*, int*) except -1

有人有什么想法吗?我已经尝试了很多东西。 我在ubuntu16上没有这个问题。

。 . .

【问题讨论】:

我会仔细检查内核版本,但如果不是 3.10+,我会感到非常惊讶 这可能是个愚蠢的问题,但你要我检查 docker 容器内的内核版本吗? 抱歉 - 澄清一下,检查 Docker 主机上的规范只是为了确保存储驱动程序和其他系统与您的构建兼容。内核版本从里到外都是一样的——因为它一样的:) 我在外部主机上运行 ubuntu 16。我可以在这个操作系统上安装这个包。它在我的 docker 容器中失败了 【参考方案1】:

这似乎是由 pymssql 的版本 2.1.12.1.3 之间的某个接口更改引起的。我没有时间调查确切原因,但在注意到centos 7.x docker 映像上仍然存在问题后,我能够通过安装更新​​版本的pymssql 来解决此问题:

pip install pymssql==2.1.3

【讨论】:

以上是关于pip 从 docker 容器内安装 pymssql的主要内容,如果未能解决你的问题,请参考以下文章

EnvironmentError: HTTPSConnectionPool 同时在 docker 容器上安装 pip

怎样从外网访问内网Docker容器

docker-compose编排项目redis容器实现主从复制

外网访问内网Docker容器

Chrome 无法从 docker 容器内的调试端口提供服务

由于从 `https://pypi.python.org/simple/` 返回的“永久移动”错误,`pip` 无法在 Docker 容器中安装包