1

I defined a custom toolbox in ArcMap 10.6, the script ran perfectly when I first use it, but ran in error when I use the same script with same parameters again. After I restart ArcMap 10.6, I can use it perfectly again.

When I use the same script in ArcGIS Pro,it run perfectly. I want to know if it is a bug? If so, is it a ArcMap's bug or a networkx package's bug or others? And what can I do?

Here is the error message:

File "******\caculate_network.py", line 7, in <module>
 import networkx as nx
 File "C:\Python27\ArcGIS10.6\lib\site-packages\networkx\__init__.py", line 128, in <module>
 import networkx.drawing
 File "C:\Python27\ArcGIS10.6\lib\site-packages\networkx\drawing\__init__.py", line 6, in <module>
 from . import nx_pydot
 File "C:\Python27\ArcGIS10.6\lib\site-packages\networkx\drawing\nx_pydot.py", line 27, in <module>
 from pkg_resources import parse_version
 File "C:\Python27\ArcGIS10.6\lib\site-packages\pkg_resources\__init__.py", line 48, in <module>
 from pkg_resources.extern import six
 File "C:\Python27\ArcGIS10.6\lib\site-packages\pkg_resources\extern\__init__.py", line 45, in load_module
 mod = sys.modules[extant]
AttributeError: 'NoneType' object has no attribute 'modules'
Kadir Şahbaz
78.6k57 gold badges260 silver badges407 bronze badges
asked Mar 20, 2020 at 14:57
3
  • My only solution is older version of networkx. Bugger. Commented Mar 20, 2020 at 20:17
  • 1
    I reduced the version of networkx to 1.11 , the problem is solved! Thank you a lot! Commented Mar 21, 2020 at 4:56
  • Unless you know how to install it using pip, keep installation package in safe place. Helps when pc breaks. Commented Mar 21, 2020 at 5:02

1 Answer 1

0

I have found a stupid workaround that worked in my case.

I could succesfully run my Python script importing tablib, but only the first run was successful. Until I have tried to import this library in Python window first before running the script. All successive script runs were without any error. Although I do not believe that it is relevant here are the specs:

ArcGIS 10.5.1 v. 7333 (no patches applied), Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)] on win32, tablib version 0.14.0

And the code that have triggered this error

import sys, arcpy, os

import tablib

and the error

Traceback (most recent call last):
 File "D:\Data\Test\TestTabLib.py", line 9, in <module>
 import tablib
 File "C:\Python27\ArcGIS10.5\lib\site-packages\tablib\__init__.py", line 2, in <module>
 from pkg_resources import get_distribution, DistributionNotFound
 File "C:\Python27\ArcGIS10.5\lib\site-packages\pkg_resources\__init__.py", line 48, in <module>
 from pkg_resources.extern import six
 File "C:\Python27\ArcGIS10.5\lib\site-packages\pkg_resources\extern\__init__.py", line 44, in load_module
 mod = sys.modules[extant]
AttributeError: 'NoneType' object has no attribute 'modules'
answered Jul 13, 2020 at 9:56
1
  • There is also another option. You can unselect the option Run Python script in process and try to run it again. In my case this failed, however I got the syntax necessary to be able to run it from the command prompt. Then I have copied this string to the command prompt and have executed the code couple of times to test it without the hitch. However, in order to run anything from the command prompt you need to point to the correct python version if you have more than one. Commented Jul 16, 2020 at 12:41

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.