简体   繁体   English

netifaces 包在 Linux 上的 Python3.4 下不起作用

[英]The netifaces package doesn't work under Python3.4 on Linux

I developed my application on Mac OS and it works fine.我在 Mac OS 上开发了我的应用程序,它运行良好。 On the Mac I get this:在 Mac 上,我得到了这个:

$ python3
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 23 2015, 02:52:03) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import netifaces
>>> netifaces.version
'0.10.4'
>>> netifaces.interfaces()
['lo0', 'gif0', 'stf0', 'en0', 'en1', 'en2', 'bridge0', 'p2p0', 'awdl0', 'utun1', 'utun0']

which is great.这很棒。 When I move the app to Linux it does not work -- I get this:当我将应用程序移至 Linux 时,它不起作用——我明白了:

~$ python3
Python 3.4.3 (default, Jun 17 2015, 22:58:00) 
[GCC 4.6.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import netifaces
>>> netifaces.version
'0.10.4'    
>>> netifaces.interfaces()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 0] Error
>>> 

I tried it under sudo and got the same thing.我在sudo下尝试过,得到了同样的结果。

Since I couldn't find a repository with Python3 in it I ended up building the Python3.4 installation from source.由于我找不到包含 Python3 的存储库,因此我最终从源代码构建了 Python3.4 安装。 Is it possible that I left something out in the build that netifaces needs?有没有可能我在构建中遗漏了 netifaces 需要的东西?

Other than that does anyone have any idea on how to proceed?除此之外,有人对如何进行有任何想法吗?

Update: My Linux is Ubuntu 12.04 (don't ask I'm stuck there for a while) and the uname -a shows:更新:我的 Linux 是 Ubuntu 12.04(不要问我被困在那里有一段时间了)并且 uname -a 显示:

Linux testsys 3.2.16oa4 #1 SMP Tue Jan 6 16:12:02 PST 2015 x86_64 x86_64 x86_64 GNU/Linux

Please include your Linux information: distribution, version.请包括您的 Linux 信息:发行版、版本。

Most likely the issue exists because you have built Python 3.4 from source code and Python require distribution specific patches to work correctly on your specific version of Linux.问题很可能存在,因为您已经从源代码构建了 Python 3.4,并且 Python 需要分发特定的补丁才能在您的特定 Linux 版本上正常工作。 These patches might be omitted from source code distributed on python.org.这些补丁可能会从 python.org 上分发的源代码中省略。 Consult your distribution issue tracker.请咨询您的分发问题跟踪器。

For Ubuntu use deadsnakes repository when installing Python:对于 Ubuntu,在安装 Python 时使用 deadsnakes 存储库:

https://launchpad.net/~fkrull/+archive/ubuntu/deadsnakes https://launchpad.net/~fkrull/+archive/ubuntu/deadsnakes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM