Basemap is the Matplotlib subpackage and one of the most commonly used and convenient tools for geographic data visualization in Python. The traditional Python install packages (PIP Install Basemap or Conda Install Basemap) often report errors and indicate that Python 2.7 Basemap and Python 3.6 conflict (Figure). Although 2.7 is a classic and most of the world’s data is still based on 2.x, it has been officially announced that 2.x is only for maintenance until 2020 and 3.x is the future.
The following is the Windows environment Python 3.x installation of basemap to share, for your reference.
Premise: My computer is configured 64 for Win10, Anaconda 3 (64-bit), Python 3.6.
1. First of all, download Basemap and Pyproj installation files according to your computer configuration and Python version. This website mainly provides Python Extension Packages under unofficial Windows environment
Basemap download address: https://www.lfd.uci.edu/~gohlke/pythonlibs/
Pyproj download address: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyproj
Where, 1.1.0 after basemap represents the version number, cp36 represents python3.6, win represents Windows, and amd64 represents the 64-bit system. Basemap is about 120M, Pyproj is only about 3M.
2. Win +R opens the command prompt window, and the CD command sets the current directory to the folder where the download files are stored (I put it on the desktop) and then hits enter. Note: If you are using Spyder version 3.2 or above, please execute the following installation command on Anaconda Prompt (my_root), following the same steps.
3. Then start installing the two files, starting with Pyproj
PIP install pyproj 188.8.131.52 – cp36 – cp36m – win_amd64. WHL
Note that the full name of the file name and the suffix (.whl) cannot be lost, and the same command will install Basemap after successful installation
PIP install basemap – 1.1.0 – cp36 – cp36m – win_amd64. WHL
An error occurs here
You are using PIP version 9.0.1, however version 9.0.2 is available.
You should consider upgrading via the ‘python -m pip install –upgrade pip’ command.
The installation was successful using the easy_install directive:
, first go to the directory of easy_install such as C:\ProgramData\Anaconda3\Scripts
, then through the directive easy_install.exe PIP ==9.0.2 and finally install successfully.
And then install it
Successfully installing prompts you to install.
4. Then test whether the installation is successful
import numpy as np import pandas as pd import xarray as xy import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap import os os.chdir(r'F:\NCEP') temp = xy.open_dataset('air.mon.mean.v401.nc') air = temp['air'] T30 = temp.sel(time=slice('1981-01-01', '2010-12-01')) t_average = T30.groupby('time.year').mean(dim='time') t = t_average.mean(dim='year') tmp = t['air'] lon = t['lon'][:] lat = t['lat'][:] lon, lat = np.meshgrid(lon, lat) def plt_map(data): m = Basemap(projection='mill', llcrnrlat=-90, urcrnrlat=90, llcrnrlon=-180, urcrnrlon=180, lat_ts=30, resolution='c') x, y = m(lon, lat) plt.xlim(-180, 180) plt.figure(figsize=(10, 7)) m.drawcoastlines() m.drawparallels(np.arange(-90., 91., 30.)) m.drawmeridians(np.arange(0., 361., 30)) m.drawmapboundary(fill_color='white') m.contourf(x, y, data, levels=np.linspace(-25, 30, 56), extend='both') plt.colorbar(orientation='horizontal', pad=0.05) plt_map(tmp)
- Installing PyQt4 in Windows + Python 3.6
- Anaconda + vscode usage problem summary
- cannot import name ‘_validate_lengths’ from ‘numpy.lib.arraypad’
- Import any QT binding error during installation of evo
- Installing gensim in Anaconda
- Anaconda Matplotlib drawing Chinese garbled solution
- Data analysis to obtain Yahoo stock data: some problems are encountered when using panda datareader (cannot import name ‘is_ list_ Like ‘problem)
- ModuleNotFoundError: No module named ‘numpy.testing.nosetester‘
- Installation of Python on MAC
- To solve Anaconda error: command error out with exit status 1
- In Python, import XXX does not report an error, but in IPython (Jupiter notebook)
- Finally solved the importError: DLLload failed: the specified module could not be found when import matplotlib.pyplot
- Importing the multiarray numpy extension module failed
- [Python error] using PIP / easy under Windows_ Fail error in launcher: unable to create process using
- Package summary of installing python with CONDA
- AttributeError:‘AxesSubplot’object has no attribute‘bar_label’
- [error reported] [Python] [Matplotlib] importerror: failed to import any QT binding
- Installing flash in MAC environment
- On the problem of from PIL import image
- CONDA creating virtual environment and common CONDA commands