NameError: name 'basestring' is not defined in example script

Khary Richardson
  • 30 Apr '15

Hello, When trying to run the first API example in the example scrips I get the following error

File "C:\WinPython-64bit-\python-3.4.3.amd64\lib\site-packages\illustris_python\", line 20, in loadObjects if isinstance(fields, basestring):

NameError: name 'basestring' is not defined

I looked in the groupcat file and it indeed looks as if basestring is never definded.

Thank you

Dylan Nelson
  • 1 May '15

Hi Khary,

Seems this is a Python 3 issue (the examples were developed in Python 2).

You can implement the fix described at

or you can just delete these two lines of the script, so long as you understand what they are protecting you against. In particular, that fields=["Masses","Coordinates"] and fields=["Masses"] are ok, but fields="Masses" is going to cause problems.

Khary Richardson
  • 2 May '15

The fix linked above worked perfectly. Thank You!

  • Page 1 of 1