Failing at first hurdle using pcapng in python 3.8; unable to import FileScanner SOLVED I had one line too many

175 Views Asked by At

This is my first attempt at writing python code; I think I'm using 3.8.5. Ironically, I have many versions of python installed, and maybe that is where I'm going wrong. But I don't see it. Everywhere I look, the very first line of code I find is from pcapng import FileScanner but I cannot get it to work. <EDIT 'pip install pcapng' is the problem />

$ 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)

coding

import pcapng
help(pcapng)

gives me

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

Where am I going wrong?

1

There are 1 best solutions below

0
On

It seems that my naive attempt to install Python's pcapng with

pip install pcapng

was fundamentally flawed. It should just be

pip install python-pcapng