Python NetworkX Module in ArcPy – How to Resolve ‘No Module Named Networkx’ Error

arcpyinstallationnetworkxpython-window

I'm trying to import the module networkx with the Python console in ArcGIS, but I keep getting the error "no module named networkx".
I have installed it with the command "pip install networkx".

How can I fix this error?

Best Answer

I guess you didn't install networkx in the ArcGIS Python environment you are currently using in ArcGIS. To be sure, that you choose the right enviromnent you should change the working Directory to the Scripts Folder of the right Python environment, before installing networkx via pip install networkx command. E.g.:

ArcGIS Pro:

cd C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Scripts

ArcGIS Desktop (32-bit):

cd C:\Python27\ArcGIS10.x\Scripts

ArcGIS Desktop (64-bit):

C:\Python27\ArcGISx6410.x\Scripts