5

I have installed mininet on my computer and now I want to run a python script with mininet. How should I do so?

If I just use python3 star.py, I get an error that:

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

If I try sudo mn python3 star.py, then I get

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

and if I try sudo mn and then python star.py, that doesnt work either.

x89
  • 2,798
  • 5
  • 46
  • 110
  • I don't need to run miniedit. I just need to run a python script on mininet. Miniedit is different. @Karthik – x89 Sep 12 '20 at 15:45
  • I never run mininet before but if you want to run commands in CLI then you can put them in file - ie. `my_commands.txt` - and redirect `su mn < my_commands.txt` – furas Sep 13 '20 at 11:07
  • 1
    I can't `import mininet` in `Python 3` but it works in `Python 2`. It seems it installed module in `Python 2` but not in `Python 3` – furas Sep 13 '20 at 11:10

2 Answers2

2

Try to download the Mininet code, and export the path.

Example:

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

Giuseppe
  • 658
  • 1
  • 6
  • 14
0

You might still need to do pip install mininet even if you had installed Mininet using the procedure in the documentation.

LKK
  • 1
  • 2
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 09 '23 at 22:14