16

I've found that the Basemap (module for matplotlib and Python) binary installer for Windows cannot detect Python on the system when Python is installed as part of a stack install, like Anaconda or WinPython. The installer exits, rather than allow you to point to the directory of installation.

I have to therefore install via source. However, I don't know the method to do this. The Readme.txt and install instructions don't seem to help. They simply instruct to "install geos-3.3.3 first" - well, how exactly? I don't see a setup.py in that directory.

Any help would be great. (Python 2.7, Win 7, 64b)

r4gt4g
  • 304
  • 1
  • 2
  • 11

2 Answers2

41

I use windows. And my installation failed with official guidance, too. Finally I installed Basemap using the following method. Although I am not sure if it will go right for you, I just offer mine.

  1. First of all, you must have pip in your computer. (It is much easier to install, compared with Basemap and other things. And it can be used to install many useful packages.)

  2. Then go this great link: http://www.lfd.uci.edu/~gohlke/pythonlibs/

    And download the file named "basemap‑1.1.0‑cp27‑cp27m‑win32.whl".

  3. Move the .whl file to directory "C:\Python27". (Maybe you installed your python in different disk, then change it accordingly.)

  4. Open terminal. (Use cmd or Git Bash or something else.)

  5. Use command:

    pip install basemap‑1.1.0‑cp27‑cp27m‑win32.whl

Ashuthosh
  • 81
  • 10
Temy
  • 636
  • 9
  • 10
  • 2
    So this worked for me too. After trying out 10 different guides, this was the one that worked. Make sure though to use the correct file, mine was basemap-1.0.8-cp27-none-win32.whl. Thanks for posting this here. – ninehundred Nov 09 '15 at 17:05
  • 2
    If you have 32bit python on 64 bit machine you need the 32bit version of basemap. The CP part stands for your python verion (i.e. 2.7 in this case) – Rutger Hofste Dec 07 '16 at 22:03
  • Also, for me it only worked if I installed matplotlib first – Rutger Hofste Dec 07 '16 at 22:11
  • 2
    Thank you!! I had been trying various guides for an hour until I found this. ...A quick note that I needed to install [pyproj](http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyproj) before basemap. Same process, just save the .whl file to your folder, and pip install it. Without PyProj, I was getting "Command "python setup.py egg_info" failed with error code 1..." – BruceWayne Jun 18 '17 at 00:15
  • 1
    Do you mean "Move the .whl file" on 3rd step? – nurp Oct 20 '17 at 06:22
  • If Python is installed using Cygwin then there is no \Python directory, but instead in 'C:\cygwin64\bin\' - should the WHL file be moved there? – yeliabsalohcin Jun 18 '18 at 15:36
  • you can also set a path you wish like: py -m pip install "C:\maxbook\maxboxpython\basemap-1.2.0-cp37-cp37m-win_amd64.whl" then you get: Successfully built pyshp Installing collected packages: pyshp, pyproj, basemap Successfully installed basemap-1.2.0 pyproj-2.1.3 pyshp-2.1.0 – Max Kleiner May 19 '19 at 12:54
1

The following worked for me using Python 3.10.1.

Setup environment using terminal in Visual Studio Code (https://code.visualstudio.com/docs/python/python-tutorial):

py -3 -m venv .venv
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
.venv\scripts\activate

Install basemap using pip:

pip install matplotlib
pip install basemap-data
pip install basemap-data-hires
pip install basemap

Create file with code from: https://matplotlib.org/basemap/users/examples.html

Remember to select the correct interpreter (In VSCode use Ctrl+Shift+P to select interpreter).

That's it.

Torkil Kollsker
  • 291
  • 2
  • 4