Python ospybook library installation tutorial

Download the ospybook package

Link: https://www.manning.com/books/geoprocessing-with-python?a_bid=c3bae5be&a_aid=geopy

Click on Source Code in the lower left corner to download

Insert image description here

Install the ospybook package

1. First decompress the downloaded osgeopy-code.zip, then decompress the ospybook-latest.zip inside, and find the setup.py file inside.
Insert image description here
2. Open cmd and locate the setup.py folder (because The location where I store it is on the D drive, so here I take the D drive as an example)
First enterD:

Enter again cd D:\software\Pycharm\list\osgeopy-code\ospybook-latest\ospybook-1.0and enter the path under setup.py in the D drive.
Insert image description here

Enter command linepython setup.py build

After completion, enter the command line python setup.py installto install

After successful installation, enter pip listto view the installation list
Insert image description here

Solution to error when running

After installation, you can import the library into pycharm import ospybookfor use, but an error occurred here:ModuleNotFoundError: No module named 'osgeo'

Insert image description here

After this problem occurs, you can try to install the gdal library, but if you use it directly pip install gdal, you will most likely get an error. Therefore, you need to download the corresponding GDAL installation file from the official website according to your python version.

Download address: https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal
Insert image description here

After downloading, enter in cmd pip install D:\software\Pycharm\list\GDAL-3.4.3-cp311-cp311-win_amd64.whlto install gdal. After the installation is successful, import ospybookthere will be no problem when you run it again.

Guess you like

Origin blog.csdn.net/wongyinger/article/details/126441883