如何在Ubuntu 12.04中为Python3安装netifaces库?
我在Python3中写了一个程序,使用了一个叫netifaces的包。我在两台电脑上安装了它,分别是Ubuntu 13.04和Ubuntu 13.10,都是通过pip3安装的。不过,我现在需要在另一台装有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的文件夹做一个符号链接到这些文件夹,但也没有成功。
有没有什么建议呢?
1 个回答
10
解决了!
我还需要安装一个叫python3-dev的包,之后用pip3安装netifaces的时候就没有报错了,现在我可以正常使用它了。
所以整个过程(对我来说)是:
sudo aptitude install python3-setuptools
sudo easy_install3 pip
sudo aptitude install python3-dev
sudo pip3 install netifaces