1

I recently had to recreate an environment after updating to Mac OS Big Sur and running into a common issue with Spyder not opening. A key component of that environment is the ecco_v4_py package necessary for processing ECCO state estimate data.

I managed to get the package installed into the environment, but whenever I try to load it in with import ecco_v4_py as ecco I get the following error.

 File "/Users/drew/anaconda3/envs/Salt/lib/python3.9/inspect.py", line 632, in cleandoc
    lines = doc.expandtabs().split('\n')

AttributeError: 'NoneType' object has no attribute 'expandtabs' 

I have tried creating a fresh environment with just ecco_v4_py and Spyder, but that gives the same error. I have also tried creating a fresh environment with a downgraded version of the package, but that also causes this error.

Looking more deeply into the issue, I go to the line in the library code that is throwing the error.

def cleandoc(doc):
    """Clean up indentation from docstrings.

    Any whitespace that can be uniformly removed from the second line
    onwards is removed."""
    try:
        lines = doc.expandtabs().split('\n') #This is the line that is failing
    except UnicodeError:
        return None
    else:
        # Find minimum indentation of any non-blank lines after first line.
        margin = sys.maxsize
        for line in lines[1:]:
            content = len(line.lstrip())
            if content:
                indent = len(line) - content
                margin = min(margin, indent)
        # Remove indentation.
        if lines:
            lines[0] = lines[0].lstrip()
        if margin < sys.maxsize:
            for i in range(1, len(lines)): lines[i] = lines[i][margin:]
        # Remove any trailing or leading blank lines.
        while lines and not lines[-1]:
            lines.pop()
        while lines and not lines[0]:
            lines.pop(0)
        return '\n'.join(lines)

But when I run just this block it works, so I'm not sure why it throws an error when I try to import the package.

Small edit: I've also tried installing an earlier version of python, but this does not solve the problem. I tried editing the file that was throwing the error to fix the problem, but further errors appear down the line.

Additional edit: I managed to get the ecco_v4_py package to work appropriately by manually going in and editing files as errors showed up. For me it required changing except UnicodeError to except (UnicodeError, AttributeError). For the remaining errors I needed to force certain variables to be interpreted as strings using the str() command. I'm still not sure if there will be unforeseen consequences of taking this brute-force approach, so I haven't marked this as the answer.

Andrew
  • 41
  • 3

0 Answers0