【问题标题】:Can't install mahotas, and installing python-dev didn't fix the error无法安装mahotas,安装python-dev也没有修复错误
【发布时间】:2016-06-13 12:12:42
【问题描述】:

我正在阅读一本教科书,其中一个示例需要 mahotas for python。我立马尝试用pip安装,立马报错:

 x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -DPY_ARRAY_UNIQUE_SYMBOL=Mahotas_PyArray_API_Symbol -I/usr/local/lib/python3.4/dist-packages/numpy/core/include -I/usr/include/python3.4m -c mahotas/_convex.cpp -o build/temp.linux-x86_64-3.4/mahotas/_convex.o
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
    In file included from mahotas/numpypp/array.hpp:17:0,
                     from mahotas/_convex.cpp:7:
    mahotas/numpypp/numpy.hpp:10:20: fatal error: Python.h: No such file or directory
     #include <Python.h>
                    ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

 ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-kzn3_c4k/mahotas/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-y19bwul7-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-kzn3_c4k/mahotas/

现在,在查找了其他 #include &lt;Python.h&gt;error: command 'x86_64-linux-gnu-gcc 错误后,我一直被告知要安装 python-dev。 不幸的是,这也立即失败了,因为python-dev 已经是最新版本,而对于python3-dev,我明白了:

The following packages have unmet dependencies:
python3-dev : Depends: libpython3-dev (= 3.4.0-0ubuntu2) but it is not going to be installed
             Depends: python3.4-dev (>= 3.4.0-0~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.   

当我尝试安装这些时?

答:

The following packages have unmet dependencies:
 libpython3-dev : Depends: libpython3.4-dev (>= 3.4.0-0~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

然后:

The following packages have unmet dependencies:
 libpython3.4-dev : Depends: libpython3.4-stdlib (= 3.4.0-2ubuntu1) but 3.4.3-1ubuntu1~14.04.3 is to be installed
                    Depends: libpython3.4 (= 3.4.0-2ubuntu1) but 3.4.3-1ubuntu1~14.04.3 is to be installed
E: Unable to correct problems, you have held broken packages.

乙:

The following packages have unmet dependencies:
 python3.4-dev : Depends: python3.4 (= 3.4.0-2ubuntu1) but 3.4.3-1ubuntu1~14.04.3 is to be installed
                 Depends: libpython3.4-dev (= 3.4.0-2ubuntu1) but it is not going to be installed
                 Depends: libpython3.4 (= 3.4.0-2ubuntu1) but 3.4.3-1ubuntu1~14.04.3 is to be installed
E: Unable to correct problems, you have held broken packages.

这是一个兔子洞。怎么逃?

【问题讨论】:

    标签: python gcc compiler-errors g++ mahotas


    【解决方案1】:

    (这里是mahotas的作者)。

    您的 Ubuntu 安装现在在 Python-dev 软件包中处于某种奇怪的状态。我的摆脱兔子洞的建议是使用 Anaconda:https://www.continuum.io/why-anaconda

    然后你可以从 conda-forge 项目中获取 mahotas:https://anaconda.org/conda-forge/mahotas

    Conda-forge 是一个社区项目,它将使其保持最新状态。 Anaconda 还有其他优势。

    【讨论】:

    • 叹息...我担心你会这么说。我前段时间安装了 anaconda,但我推迟使用它,以免过度依赖。
    • 没有办法修复我的python?
    • 编辑:我刚尝试安装它,它一直给我PermissionError: [Errno 13] Permission denied: 错误。
    【解决方案2】:

    如果你已经安装了Anaconda,可以在命令行输入如下代码:

    conda install -c conda-forge mahotas
    

    对我有用

    【讨论】: