0

这是我第一次尝试编写python代码;我我正在使用 3.8.5。具有讽刺意味的是,我安装了许多版本的 python,也许这就是我出错的地方。但我没有看到。我到处看,我找到的第一行代码是from pcapng import FileScanner,但我无法让它工作。<EDIT 'pip install pcapng' 是问题 />

$ pip install pcapng
Requirement already satisfied: pcapng in /home/bryan/.local/lib/python3.8/site-packages (0.1.25)
$ pip install python-pcapng
Requirement already satisfied: python-pcapng in /home/bryan/.local/lib/python3.8/site-packages (1.0)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from python-pcapng) (1.14.0)
$ pip --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
$ python --version
Python 3.8.10
$ python ./ReadWireSharkPoC.py 
Traceback (most recent call last):
  File "./ReadWireSharkPoC.py", line 4, in <module>
    from pcapng import FileScanner
ImportError: cannot import name 'FileScanner' from 'pcapng' (/home/bryan/.local/lib/python3.8/site-packages/pcapng/__init__.py)

编码

import pcapng
help(pcapng)

给我

Help on package pcapng:

NAME
    pcapng

DESCRIPTION
    # Copyright 2017 Brocade Communications Systems, Inc
    # 
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    # 
    #     http://www.apache.org/licenses/LICENSE-2.0
    # 
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.

PACKAGE CONTENTS
    block
    block_test
    blocks
    codec
    const
    constants (package)
    exceptions
    linktype
    mrt
    mrt_test
    option
    option_test
    pen
    scanner
    structs
    tlv
    tlv_test
    util
    util_test
    utils

FILE
    /home/bryan/.local/lib/python3.8/site-packages/pcapng/__init__.py

我哪里错了?

4

1 回答 1

0

似乎我天真地尝试安装 Python 的 pcapng

pip install pcapng

存在根本性缺陷。它应该只是

pip install python-pcapng
于 2021-10-14T03:39:17.820 回答