【问题标题】:ModuleNotFoundError: No module named 'mininet'ModuleNotFoundError:没有名为“mininet”的模块
【发布时间】:2023-03-08 06:05:02
【问题描述】:

我已经在我的电脑上安装了 mininet,现在我想用 mininet 运行一个 python 脚本。我该怎么做?

如果我只使用python3 star.py,我会收到以下错误:

Traceback (most recent call last):
  File "star.py", line 2, in <module>
    from mininet.cli import CLI
ModuleNotFoundError: No module named 'mininet'

如果我尝试sudo mn python3 star.py,那么我会得到

Usage: mn [options]
(type mn -h for details)

The mn utility creates Mininet network from the command line. It can create
parametrized topologies, invoke the Mininet CLI, and run tests.

Options:
  -h, --help            show this help message and exit

如果我尝试sudo mn 然后python star.py,那也不起作用。

【问题讨论】:

  • 我不需要运行 miniedit。我只需要在 mininet 上运行一个 python 脚本。 Miniedit 不同。 @Karthik
  • 我以前从未运行过 mininet,但如果你想在 CLI 中运行命令,那么你可以将它们放在文件中 - 即。 my_commands.txt - 并重定向su mn &lt; my_commands.txt
  • 我不能在Python 3 中使用import mininet,但它在Python 2 中有效。似乎它在Python 2 中安装了模块,但在Python 3 中没有安装模块

标签: python linux networking virtual-machine mininet


【解决方案1】:

尝试下载Mininet代码,并导出路径。

例子:

sudo -i
cd ~
git clone https://github.com/mininet/mininet.git
export PYTHONPATH=$PYTHONPATH:$HOME/mininet
python3 star.py

【讨论】:

    猜你喜欢
    • 2019-03-28
    • 2022-01-07
    • 2017-12-14
    • 2020-12-10
    • 2021-09-02
    • 2020-10-10
    • 2022-01-06
    • 2021-09-10
    相关资源
    最近更新 更多