-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional python packaging documentation, version correction #9405
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -36,35 +36,54 @@ Once you have Anaconda or Miniconda installed, you should be able to install GDA | |||||
|
||||||
``conda install -c conda-forge gdal`` | ||||||
|
||||||
Unix | ||||||
~~~~ | ||||||
|
||||||
The GDAL Python bindings requires setuptools. | ||||||
|
||||||
pip | ||||||
~~~ | ||||||
|
||||||
GDAL can be installed from the `Python Package Index <https://pypi.org/project/GDAL>`__: | ||||||
GDAL can be installed from the `Python Package Index <https://pypi.org/project/GDAL>`__. | ||||||
Due to the complex nature of GDAL and its components, different bindings may require additional packages installation steps. | ||||||
The base GDAL package contains support for OGR, OSR, and GDAL vectors: | ||||||
|
||||||
:: | ||||||
|
||||||
pip install gdal | ||||||
|
||||||
It will be necessary to have libgdal and its development headers installed | ||||||
if pip is expected to do a source build because no wheel is available | ||||||
for your specified platform and Python version. | ||||||
|
||||||
To install with numpy support, you need to require the optional numpy component: | ||||||
In order to enable raster support, libgdal and its development headers must be installed as well as the Python packages numpy, setuptools, and wheel. | ||||||
To install the Python dependencies and build raster support: | ||||||
|
||||||
|
||||||
:: | ||||||
|
||||||
pip install numpy>1.0.0 wheel setuptools>=67 | ||||||
pip install gdal[numpy]=="$(gdal-config --version).*" | ||||||
|
||||||
|
||||||
Users can verify that reaster support has been installed with: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
:: | ||||||
|
||||||
python3 -c 'from osgeo import gdal_array' | ||||||
|
||||||
|
||||||
If this command raises an ImportError, raster support has not been properly installed: | ||||||
|
||||||
:: | ||||||
|
||||||
Traceback (most recent call last): | ||||||
File "<string>", line 1, in <module> | ||||||
File "/usr/local/lib/python3.12/dist-packages/osgeo/gdal_array.py", line 10, in <module> | ||||||
from . import _gdal_array | ||||||
ImportError: cannot import name '_gdal_array' from 'osgeo' (/usr/local/lib/python3.12/dist-packages/osgeo/__init__.py) | ||||||
|
||||||
pip install gdal[numpy] | ||||||
|
||||||
To install the version of the Python bindings matching your native GDAL library: | ||||||
This is most often due to pip reusing a cached GDAL installation. | ||||||
Verify that the necessary dependencies have been installed and then run the following to force a clean build: | ||||||
|
||||||
:: | ||||||
pip install --no-cache --force-reinstall gdal[numpy]=="$(gdal-config --version).*" | ||||||
|
||||||
|
||||||
pip install gdal=="$(gdal-config --version).*" | ||||||
|
||||||
Building as part of the GDAL library source tree | ||||||
------------------------------------------------ | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"raster support". Well GDAL without numpy does support raster, it is just that it is not very convenient if you need to inspect array values, but you can for example script raster conversion with gdal.Translate() without requiring numpy. Maybe use "numpy-based raster support" ? (here and below). The sentence "The base GDAL package contains support for OGR, OSR, and GDAL vectors:" above should also be reworked, as it gives the impression that there's no raster support at all