【问题标题】:How to install the library netifaces for Python3 in Ubuntu 12.04?如何在 Ubuntu 12.04 中为 Python3 安装库 netifaces?
【发布时间】:2014-09-07 23:06:49
【问题描述】:

我用 Python3 编写了一个程序,它使用了 netifaces 包,我用 pip3 在两台装有 Ubuntu 13.04 和 Ubuntu 13.10 的计算机上安装了它。但是,我需要将它安装在其他具有 Ubuntu 12.04 的计算机上,在这里我无法安装 pip3 (python3-pip),因为它不在存储库中。

我所做的是接下来的步骤:

sudo aptitude install python3-setuptools
sudo easy_install3 pip

然后我有了 pip3 可用。问题是当我尝试使用 pip3 安装 netifaces 时,这给了我下一个错误:

error: command 'gcc' failed with exit status 1
Command /usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/netifaces/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gkaftl-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/netifaces
Storing debug log for failure in /home/anubia/.pip/pip.log

如果我使用 pip 或 aptitude 或 apt-get 安装 netifaces,程序将无法识别该库,因为它的文档安装在 python2 文件夹中。我什至尝试从 python3 文件夹到它们的符号链接,但它没有工作。

有什么想法吗?

【问题讨论】:

    标签: python python-3.x ubuntu pip


    【解决方案1】:

    解决了!

    我也必须安装包python3-dev,然后从pip3安装netifaces没有给我错误,现在我可以使用它了。

    所以整个过程(就我而言)是:

    sudo aptitude install python3-setuptools
    sudo easy_install3 pip
    sudo aptitude install python3-dev
    
    sudo pip3 install netifaces
    

    【讨论】:

    • 在我的情况下,至少缺少一个 .h 头文件,该文件显然位于 python3-dev 库中。我在 ubuntu xenial 上,不要在 python 中编程,所以默认情况下没有加载开发库。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-05
    • 1970-01-01
    • 2017-12-29
    • 1970-01-01
    相关资源
    最近更新 更多