Python 在 DoHlyzer 工具中找不到模块
Python module can't be found in DoHlyzer tool
我正在尝试使用 DoHlyzer tool。当我启动位于 meter 文件夹中的 dohlyzer.py
时,出现错误
File "dohlyzer.py", line 8, in <module>
from meter.flow_session import generate_session_class
ModuleNotFoundError: No module named 'meter'
虽然文件夹 meter 有 flow_session.py
文件。
问题是此代码未正确构建,因为它认为自己是作为模块安装的,而没有提供正确的设置。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
我正在尝试使用 DoHlyzer tool。当我启动位于 meter 文件夹中的 dohlyzer.py
时,出现错误
File "dohlyzer.py", line 8, in <module> from meter.flow_session import generate_session_class ModuleNotFoundError: No module named 'meter'
虽然文件夹 meter 有 flow_session.py
文件。
问题是此代码未正确构建,因为它认为自己是作为模块安装的,而没有提供正确的设置。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