-2

here the code:

from mininet.net import Mininet
# from mininet.util import createLink

net = Mininet()
# Creatng nodes in the network.
c0 = net.addController()
h0 = net.addHost('h0')
s0 = net.addSwitch('s0')
h1 = net.addHost('h1')
# Creating links between nodes in network
net.addLink(h0, s0)
net.addLink(h1, s0)
# Configura:on of IP addresses in interfaces
h0.setIP('192.168.1.1', 24)
h1.setIP('192.168.1.2', 24)
net.start()
net.pingAll()
net.stop()

the output is:

Traceback (most recent call last):
  File "C:\Users\Asus\PycharmProjects\SDN\main.py", line 1, in <module>
    from mininet.net import Mininet
  File "C:\Users\Asus\PycharmProjects\SDN\venv\Lib\site-packages\mininet\net.py", line 99, in <module>
    from mininet.cli import CLI
  File "C:\Users\Asus\PycharmProjects\SDN\venv\Lib\site-packages\mininet\cli.py", line 31, in <module>
    from select import poll, POLLIN
ImportError: cannot import name 'poll' from 'select' (C:\Users\Asus\AppData\Local\Programs\Python\Python311\DLLs\select.pyd)

I want to know the cause of the error, knowing that I am new to Python and Mininet any idea please ?

deceze
  • 510,633
  • 85
  • 743
  • 889
  • Mininet isn't compatible with Windows. It requires a Linux (or possibly some other Unix) OS. On Windows you must use a VM. Did you spend any time at all researching this? I googled "mininet windows" and one of the "People also ask" results was "Can I use Mininet on Windows?" – Kurtis Rader Jul 23 '23 at 03:47

1 Answers1

0

The problem seems to be caused by "C:\Users\Asus\PycharmProjects\SDN\venv\Lib\site-packages\mininet\cli.py". It is trying to import a function 'poll', from 'select'. I read the Python docs about the built-in module 'select' (https://docs.python.org/3/library/select.html#select.poll), and it says

select.poll()
(Not supported by all operating systems.) Returns a polling object, which supports registering and unregistering file descriptors, and then polling them for I/O events; see section Polling Objects below for the methods supported by polling objects.

From this, I can assume that your operating system probably does not support that function. I hope that you can sort out the problem. I recommend that if you haven't already, read the docs about Mininet and the select module (linked above). Good luck!

Ed1312
  • 1
  • 3