I could successfully install the networkx package using pip install networkx command.
I have moved this post to the Tableau External Services section of the Tableau Community. This is the best place to ask questions regarding TabPy.
Looks like you got it resolved. Thank you for coming back sharing the information and marking the correct answer.