在DoHlyzer工具中找不到Python模块

问题描述

我正在尝试使用DoHlyzer tool。启动仪表表文件夹中的dohlyzer.py时出现错误

File "dohlyzer.py",line 8,in <module>  
    from meter.flow_session import generate_session_class  
ModuleNotFoundError: No module named 'meter'

尽管文件夹计量器具有flow_session.py文件

解决方法

问题在于此代码未正确构建,因为它认为自身已作为模块安装,而没有提供适当的setup.py/pyproject.toml文件以使其可安装。

因此,作为一种快速有效的方法,可以添加示例setup.py文件,以便您可以安装该工具:

#!/usr/bin/env python

from setuptools import setup,find_packages

setup(
    name="dohlyzer",description="Set of tools to capture HTTPS traffic,extract statistical and time-series features from it,and analyze them with a focus on detecting and characterizing DoH (DNS-over-HTTPS) traffic.  ",long_description=open('README.md').read(),long_description_content_type="text/markdown",url="https://github.com/ahlashkari/DoHlyzer",packages=find_packages(exclude=[]),python_requires=">=3.6",install_requires=open('requirements.txt').read().split('\n'),entry_points={
        "console_scripts": [
            "dohlyzer=meter.dohlyzer:main",]
    },)

要测试您是否可以使用virtualenv,请执行以下操作:

% virtualenv venv
% venv/bin/pip install .
% venv/bin/dohlyzer -h
usage: dohlyzer [-h] (-n INPUT_INTERFACE | -f INPUT_FILE) (-c | -s) output

positional arguments:
  output                output file name (in flow mode) or directory (in sequence mode)

optional arguments:
  -h,--help            show this help message and exit
  -n INPUT_INTERFACE,--online INPUT_INTERFACE,--interface INPUT_INTERFACE
                        capture online data from INPUT_INTERFACE
  -f INPUT_FILE,--offline INPUT_FILE,--file INPUT_FILE
                        capture offline data from INPUT_FILE
  -c,--csv,--flow     output flows as csv
  -s,--json,--sequence
                        output flow segments as json

或者您可以在全局范围内安装它:

% pip install .

N.B .:该setup.py文件有几个问题,仅对快速破解有用,如果您想使其整洁,建议您阅读some documentation about it