I was have the same error with importing Basemap from when I pass from python 3.2.7 to 3.3.6.
The error message comes from the fact that you try to import Basemap from mpl_toolkits.basemap, but the mpl_toolkits.basemap module requires to import the dedent function from the matplotlib.cbook module, but this function is not there.
So I guess there were two possible solution : to comment the line which import this function or to copy it. I chose the second option.
I don't know why the dedent function is not present in the matplotlib.cbook module.
Here it is the dedent funtion as I found it on the link I put, it was also have for header : @deprecated("3.1", alternative="inspect.cleandoc")
def dedent(s):
"""
Remove excess indentation from docstring *s*.
Discards any leading blank lines, then removes up to n whitespace
characters from each line, where n is the number of leading
whitespace characters in the first line. It differs from
textwrap.dedent in its deletion of leading blank lines and its use
of the first non-blank line to determine the indentation.
It is also faster in most cases.
"""
# This implementation has a somewhat obtuse use of regular
# expressions. However, this function accounted for almost 30% of
# matplotlib startup time, so it is worthy of optimization at all
# costs.
if not s: # includes case of s is None
return ''
match = _find_dedent_regex.match(s)
if match is None:
return s
# This is the number of spaces to remove from the left-hand side.
nshift = match.end(1) - match.start(1)
if nshift == 0:
return s
# Get a regex that will remove *up to* nshift spaces from the
# beginning of each line. If it isn't in the cache, generate it.
unindent = _dedent_regex.get(nshift, None)
if unindent is None:
unindent = re.compile("\n\r? {0,%d}" % nshift)
_dedent_regex[nshift] = unindent
result = unindent.sub("\n", s).strip()
return result
I copy the function dedent from the site of matplotlib : https://matplotlib.org/3.1.1/_modules/matplotlib/cbook.html#dedent inside the module init.py - matplolib\cbook.
And now it is working for me.
Be aware to copy it at the correct line, because some of its variable pre-defined in the module such as : _find_dedent_regex for the line :
match = _find_dedent_regex.match(s)
and _dedent_regex for the lines :
unindent = _dedent_regex.get(nshift, None)
if unindent is None:
unindent = re.compile("\n\r? {0,%d}" % nshift)
_dedent_regex[nshift] = unindent
This is where I put the function in the moddule
I deeply apologize for spelling and/or grammar errors that I could do, I will do my best to correct those I would have missed and reported to me.
I hope this was usefull.
matplotlib
? – Luffa