0

This question is not a duplicate of Basemap error: module object is not callable

The solution to that is to ensure the b in Basemap is capitalised. I am getting this problem regardless of that. Here's my code:

from mpl_toolkits.basemap import Basemap
Basemap()

And here's the error:

TypeError: 'module' object is not callable

This is a simple way of recreating the error. In reality, I am mimicking code found in pysplit, in the mapdesigner.py file on line 309.

If anyone knows a way to fix this issue please let me know.

edit:

Here's the full error:

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    Basemap()
TypeError: 'module' object is not callable

From an actual python file:

Traceback (most recent call last):
  File "C:\Users\usr\Desktop\stuff\test2.py", line 2, in <module>
    Basemap()
TypeError: 'module' object is not callable
Recessive
  • 1,780
  • 2
  • 14
  • 37
  • 2
    Show the exact, complete error message, including full stack trace. – user2357112 Oct 30 '19 at 02:41
  • It seems like `mpl_toolkits.basemap` has been [deprecated](https://matplotlib.org/basemap/index.html#deprecation-notice). – felipe Oct 30 '19 at 02:50
  • Also, possible [duplicate](https://stackoverflow.com/questions/40374441/python-basemap-module-impossible-to-import). Hopefully it helps you out. – felipe Oct 30 '19 at 02:51
  • Possible duplicate of [Python basemap module impossible to import](https://stackoverflow.com/questions/40374441/python-basemap-module-impossible-to-import) – felipe Oct 30 '19 at 02:56
  • The question does not provide enough information to know why this simply command fails for you. What happens if in a command line you do `python -c "from mpl_toolkits.basemap import Basemap; Basemap()"`? Also, do you have a file called `Basemap.py` in your folder that would shaddow the real basemap module? – ImportanceOfBeingErnest Oct 30 '19 at 03:12
  • @user2357112 I edited to included the full error traceback. That's why I didn't include it in the error, because it's not very useful – Recessive Oct 30 '19 at 03:45
  • @FelipeFaria That doesn't help me, the package I'm using uses it regardless of whether it's deprecated or not – Recessive Oct 30 '19 at 03:47
  • @ImportanceOfBeingErnest Yeh that was my first thought about the shadowing, and no I don't have another file named `Basemap.py`. Running `python -c "from mpl_toolkits.basemap import Basemap; Basemap()"` produces exactly the same error. – Recessive Oct 30 '19 at 03:50
  • @FelipeFaria I don't have any problem importing `Basemap`, only using it. So I don't get the same error as in the duplicate you included – Recessive Oct 30 '19 at 03:51
  • @Recessive Understood. Perhaps the post can help anyhow -- would recommend browsing through its answer. – felipe Oct 30 '19 at 12:46

1 Answers1

0

The method I used to install Basemap (whichever it is, I can't remember because it was months ago) didn't install Basemap, instead it placed Basemap with a setup.py file ready to be installed in my site-packages.

This setup.py of course doesn't work, but that's a separate issue. At least I know why this isn't working.

Recessive
  • 1,780
  • 2
  • 14
  • 37
  • Have a look here (https://stackoverflow.com/a/53292945/10640534) for how to install Basemap on Ubuntu. :) – Patol75 Oct 30 '19 at 04:59