How to Install Matplotlib Basemap Module on Windows 7 with WinPython (or any Python stack install)?

StackOverflow https://stackoverflow.com/questions/18109859

  •  23-06-2022
  •  | 
  •  

Pregunta

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)

¿Fue útil?

Solución

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

Otros consejos

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top