pynids(nids)使用python3导入错误

时间:2017-08-26 16:51:26

标签: python python-3.4 python-import

我已经在Raspberry Pi v.2上安装了pynids(pynids-0.6.3),它运行Jessie Light来自目录/usr/local/share/pynids-0.6.3中的https://bitbucket.org/jmichel/pynids,如下所示: `

cd /usr/local/share/pynids-0.6.3 
python3 setup.py build 
python3 setup.py install
python  setup.py install `

就我所知,python2和python3的安装都没问题:

~> pip show pynids
---
Name: pynids
Version: 0.6.3
Location: /usr/local/lib/python2.7/dist-packages
Requires:

~> pip3 show pynids
---
Name: pynids
Version: 0.6.3
Location: /usr/local/lib/python3.4/dist-packages
Requires:

nids模块位于我认为应该的位置:

~> find /usr/local/lib -name nids*
/usr/local/lib/python3.4/dist-packages/nidsmodule.cpython-34m.so
/usr/local/lib/python2.7/dist-packages/nidsmodule.so

在python2中导入nids也可以正常工作:

~> python
Python 2.7.9 (default, Mar  8 2015, 00:52:26)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import nids
>>>

但是当尝试在python3中导入nids时,我收到导入错误,说没有nids模块:

~> python3
Python 3.4.2 (default, Oct 19 2014, 13:31:11)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nids
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'nids'
>>>

可能是什么问题?

1 个答案:

答案 0 :(得分:0)

问题解决了!这是setup.py

中的一个错误

在/usr/local/share/pynids-0.6.3中的setup.py中,名称/文字&#34; nidsmodule&#34;被改为&#34; nids&#34;。现在导入也适用于Python3。

        ext_modules = [ Extension(
                        "nids",
                        #"nidsmodule",
                        define_macros = [
                            #("DEBUG", None),
                            #("ENABLE_TCPREASM_DEBUG", None),
                            ("ENABLE_TCPREASM", None),
                        ],
                        sources=["nidsmodule.c"],
                        include_dirs = INCLUDE_DIRS,
                        libraries = ["pcap", "net", "glib-2.0", "gthread-2.0"],
                        library_dirs = LIBRARY_DIRS,
                        extra_objects = EXTRA_OBJECTS
                    ) 
                  ],
    url = "https://bitbucket.org/jmichel/pynids"
    )