romeoPH
romeoPH

Reputation: 219

Even if networkx is installed, it still throws a ModuleNotFoundError: No module named 'networkx'

I successfully installed networkx using pip install networkx. I also tested it with Python using command prompt, and it worked.

Picture of running the 'pip install networkx' command and testing it afterwards with cmd

Now, when I tried importing the module in Python IDLE, it throws the following error:

    Traceback (most recent call last):
  File "C:/Users/hp/Desktop/PROJECTS/osmnx/test.py", line 1, in <module>
    import networkx
ModuleNotFoundError: No module named 'networkx'

Here's a picture that shows that I did the import statement correctly and the error.

Upvotes: 7

Views: 20164

Answers (2)

Grigory
Grigory

Reputation: 679

If your script is running using conda environment you can use: conda install networkx -y

So this will install networkx using conda package manager. It helped for my case: import networkx started working.

Upvotes: 2

romeoPH
romeoPH

Reputation: 219

I solved the problem by upgrading my Python from 3.7.3 to 3.8.5. I ran the import statement after that, but it showed the same error. With that, what I did is to run the pip install networkx again in the Command Prompt, and it finally worked!

Upvotes: 1

Related Questions