Home > Software engineering >  networkx module is not found in python
networkx module is not found in python

Time:09-12

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

CodePudding user response:

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 !!!

CodePudding user response:

The problem may be you have installed pip but it does reside in the path you can use. Although pip is installed, the script is unable to locate it. You can check:

https://blog.finxter.com/fixed-modulenotfounderror-no-module-named-networkx/

  • Related