networkx module is not found in python

Viewed 26

i am new to python and networkx

PS: I am in VS code

when i run

python --version

i get python 3.10.6

and i installed a package networkx with

pip install networkx

and when i import that package with

import networkx as nx

i get this error

enter image description here

2 Answers

This is how i resolved it, i think it was saying it because when i had installed it, the default python command was executing python v2.

Even though when i had done

pip install networkx

it had said it was successfully installed with other trivial information, i believe it was not installed properly because according to documentation networkx require python v3.

so i changed my python command pointing to python 3 or default python as python 3 (because it turned out there are multiple version of python installed in my system - as a dependency by other windows app ( i guess) ).

I isntalled networkx again with

 pip install networkx 

and this time

enter image description here

and when i run my code now, there is no error !!!

and yes lint is still showing warning but i will explore further why it is showing that in my case !!

Happy learning !!!

Related