'Python: Can't import networkx module

I want to make some graphs with Python. I am trying to import this library called networkx. I ran the command pip install networkx in my Python folder. Tried to import the library but error messages came along. I tried to run pip install networkx again and these messages came along:

requirement already satistfied.... (use -upgrade to upgrade)...

It should have been installed but when I run file networkx * i get syntax error and for import networkx I get no module named networkx. What is wrong?

I want to ask is the the python directory the place to install libraries, what are good libraries for drawing graphs and do I have to add the libraries to the PATH, when I add them.



Solution 1:[1]

I had the same issue.

For me networkx was not installed when I first called it. When I installed it somehow it wasn't updated to be available in the script.

So I made a new file, dragged and dropped the whole code into there and magically it worked.

Not sure what happened, but I'm using Visual Studio Code, maybe it's an issue with the interpreter...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Walter Reuther