如何在Ubuntu 12.04中安装Python3的库netifaces?

for*_*vas 2 python ubuntu pip python-3.x

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

我做的是接下来的步骤:

sudo aptitude install python3-setuptools
sudo easy_install3 pip
Run Code Online (Sandbox Code Playgroud)

然后我有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
Run Code Online (Sandbox Code Playgroud)

如果我用pip或aptitude或apt-get 安装netifaces,程序无法识别库,因为它的文件安装在python2文件夹中.我甚至试图从python3文件夹到它们做一个符号链接,但它没有用.

请问有什么想法吗?

for*_*vas 8

解决了!

我不得不安装包python3-dev,然后从pip3安装netifaces没有给我一个错误,现在我可以使用它.

所以整个过程(在我的例子中)是:

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

sudo pip3 install netifaces
Run Code Online (Sandbox Code Playgroud)