- Установка GDAL с Python на Windows?
- Issues with installing GDAL for Python 3.7.3
- 3 Answers 3
- cspanring / pip-install-gdal.md
- This comment has been minimized.
- ict4eo commented Jun 19, 2014
- This comment has been minimized.
- varnav commented Sep 2, 2015
- This comment has been minimized.
- basaks commented Jan 20, 2016
- This comment has been minimized.
- basaks commented Jan 20, 2016
- This comment has been minimized.
- enricofer commented Feb 18, 2016
- This comment has been minimized.
- jphuart commented Feb 19, 2016
- This comment has been minimized.
- jphuart commented Feb 19, 2016
- this is a YAML file holding the role tasks for installing GDAL in a virtual environment
- This comment has been minimized.
- ungarj commented Feb 25, 2016
- This comment has been minimized.
- drnextgis commented Apr 17, 2016
- This comment has been minimized.
- ghost commented Nov 20, 2016
- This comment has been minimized.
- stas53 commented Jul 14, 2017
- This comment has been minimized.
- GertS commented Sep 5, 2017
- This comment has been minimized.
- shashi9122 commented Dec 13, 2017
- This comment has been minimized.
- eugeneYWang commented Mar 7, 2018
- This comment has been minimized.
- abhijayQuantela commented May 22, 2018
- This comment has been minimized.
- denadai2 commented May 26, 2018
- This comment has been minimized.
- abhishekmaroon5 commented Jul 24, 2018
- This comment has been minimized.
- akshmakov commented Jul 27, 2018 •
- This comment has been minimized.
- prhbrt commented Aug 29, 2018
- optional: install the newest version of gdal-bin and libgdal-dev :
- required: install using pip3:
- This comment has been minimized.
- fitoprincipe commented Sep 20, 2018
- This comment has been minimized.
- skyfeature commented Sep 24, 2018
Установка GDAL с Python на Windows?
Может кто-нибудь объяснить, как установить GDAL / OGR с Python на Windows?
У меня Windows Vista, и я попытался проследить информацию на веб-сайте, и она, кажется, не связывает exe-файлы для меня.
Может кто-нибудь описать процесс, включая ссылки на нужные мне файлы / папки?
Теперь я попытался запустить установку GDAL с MinGW, но это также не удалось:
Если у вас нет веских причин не делать этого, я бы определенно рекомендовал начать с установщика OSGeo4W , который может устанавливать несколько разных версий GDAL и их соответствующие привязки Python. Он отлично работает и значительно упрощает историю развертывания Windows. В частности, вы захотите установить pkg-gdal-python , который находится в пределах ‘Libs’ в дереве установщика.
Его можно установить из cmd.exe, используя что-то вроде:
(Вы должны установить NumPy из того же места, используя аналогичную команду)
Хотя пакет не создан разработчиками OSGeo или GDAL, он представляет собой высококачественный дистрибутив с поддержкой последних версий GDAL, скомпилированных для 32-битных и 64-битных версий Python. Нет необходимости добавлять внешние библиотеки или управлять ими!
Обновление даже устанавливает GDAL_DATA переменную среды, если она не установлена, и включает PostgreSQL драйвер для чтения данных из PostGIS.
Другой вариант — установить дистрибутив Anaconda Python, содержащий пакеты для GDAL. Если вы собираетесь проделать большую работу, используя GDAL с другими пакетами Python (scipy, pandas, scikit-learn и т. Д.), Это может быть лучшим вариантом, чем OSGeo4W. С другой стороны, если вы хотите использовать Python в сочетании с несколькими открытыми исходными кодами и пакетами ГИС (GRASS, QGIS и т. Д.), OSGeo4W, вероятно, является лучшим вариантом.
Вы можете получить полный дистрибутив Anaconda по адресу : https://www.continuum.io/downloads, который содержит множество пакетов Python, направленных на «науку о данных», или минимальную установку с http://conda.pydata.org/miniconda. HTML
В процессе установки вам будет предложено добавить основной путь (чтобы он был доступен с любого терминала).
После настройки GDAL можно установить в новой среде, используя:
Затем активируйте его, как показано, когда команда завершится. Рекомендуется установить в новую среду, чтобы избежать конфликтов с другими пакетами и убедиться, что установлены необходимые переменные среды.
Я предложил установить их с канала conda-forge ( https://conda-forge.github.io/ ), поскольку они очень активны в поддержании своих сборок GDAL и следят за тем, чтобы они работали со многими библиотеками.
После того, как установленные пакеты могут быть обновлены из среды, используя:
Issues with installing GDAL for Python 3.7.3
I am having trouble trying to install GDAL in python 3.7.3. Does anyone out there have any experience installing this? Also, this is the first time I’m asking here. Please do assist or kindly direct me to anyone who can offer advice on this? Thanks in advance.
3 Answers 3
Chris Gohlke has a fantastic repository of pre-built python wheels for windows, amongst them GDAL .
So depending on the GDAL version desired, the python version used and your system ( win_amd64 ?) you can just download the corresponding wheel file and install it locally using pip .
E.g. to install GDAL 3.0.4 , running under python3.7 on a 64bit machine, you need to download:
pip3 install C:\Users\foo\bar\GDAL‑3.0.4‑cp37‑cp37m‑win_amd64.whl
For installing modules, especially complex like gdal, it always pays off to use a virtual environment, as provided by e.g. virtualenv .
Addding to the answer by Val, you can also try installing it with conda.
- Install Anaconda or Miniconda.
- Create a new enviroment with the Python version you need:
conda create —name MyEnviroment python=3.7.3
Enter/Activate the enviroment and install your Python packages (First the ones you need from conda like gdal, after that the ones you need from pip:
conda activate MyEnviroment
conda install gdal
pip install .
Note: You know you are inside an enviroment after you activated it because it displays the name of it before your current directory, for example: (MyEnviroment) PS D:\MY\DIRECTORY\SCRIPTS>
Run your scripts while your conda enviroment is active:
(MyEnviroment) PS D:\MY\DIRECTORY\SCRIPTS> python MyScript.py
conda deactivate
Installing conda packages usually gives less problems than installing packages from pip, because of the way the packages are made.
cspanring / pip-install-gdal.md
Installing GDAL in a Python virtual environment
Get gdal development libraries:
Create and activate a virtual environment:
Specify where the headers are:
This comment has been minimized.
Copy link Quote reply
ict4eo commented Jun 19, 2014
Running the command:
(the /usr/include/gdal/ directory does exist)
This comment has been minimized.
Copy link Quote reply
varnav commented Sep 2, 2015
For modern pip use:
pip install gdal —install-option=»—include-dirs=/usr/include/gdal/»
This comment has been minimized.
Copy link Quote reply
basaks commented Jan 20, 2016
This worked for me:
pip install gdal —global-option=build_ext —global-option=»-I/usr/include/gdal/»
you might have to change the gdal version to the version installed on your host. So I had to do this since I have gdal==1.11.2 on my host:
pip install gdal==1.11.2 —global-option=build_ext —global-option=»-I/usr/include/gdal/»
This comment has been minimized.
Copy link Quote reply
basaks commented Jan 20, 2016
Or after install gdal using these steps on host:
This comment has been minimized.
Copy link Quote reply
enricofer commented Feb 18, 2016
thanks basaks. This works for me too on Ubuntu 14.04
This comment has been minimized.
Copy link Quote reply
jphuart commented Feb 19, 2016
Thanks a lot Christian and Sudipta Basak. I spent a lot of time before falling on this page and finally it works for me either in my virtualenv on Ubuntu 14.04.
This comment has been minimized.
Copy link Quote reply
jphuart commented Feb 19, 2016
Here is my contribution on how to put all this in an ansible role, if this can help someone.
this is a YAML file holding the role tasks for installing GDAL in a virtual environment
- name: Create venvpy directory
file: path=<< GDAL_ENV_DIR >> state=directory owner=<< GDAL_OWNER >> group=<< GDAL_GROUP >> mode=0775 - name: Check that virtualenv is present
pip: name=virtualenv - name: Create the virtualenv directory for python 2.7
command: virtualenv —python=/usr/bin/python2.7 << GDAL_ENV_DIR >> —no-site-packages creates=<< GDAL_ENV_DIR >>
sudo: no - name: Ensure required packages are installed for gdal
apt: name=<< item >> state=latest update_cache=yes
with_items:- libmysqlclient-dev
- libgdal-dev
- libgdal1h
- libgdal1-dev
- name: Install libraries in the virtualenv
sudo: no
pip: name=<< item >> virtualenv=<< GDAL_ENV_DIR >> extra_args=’—global-option=build_ext —global-option=»-I/usr/include/gdal/»‘
with_items:- gdal==1.11.2
This comment has been minimized.
Copy link Quote reply
ungarj commented Feb 25, 2016
Specifying the GDAL version in pip install worked for me as well.
Thank you so much everyone!
This comment has been minimized.
Copy link Quote reply
drnextgis commented Apr 17, 2016
This comment has been minimized.
Copy link Quote reply
ghost commented Nov 20, 2016
sudo apt-get install python-gdal
sudo apt-get install gdal-bin
This comment has been minimized.
Copy link Quote reply
stas53 commented Jul 14, 2017
bosaks advice worked for me.
However, I had had to do
sudo pip install .
instead of just
pip install .
Thanks a lot !
Stanislaw R.
This comment has been minimized.
Copy link Quote reply
GertS commented Sep 5, 2017
Thanks @basaks, you’ve made my day. The latest version of GDAL does not even have a corresponding pygdal version.
This comment has been minimized.
Copy link Quote reply
shashi9122 commented Dec 13, 2017
During installation of sumo in ubuntu 14.10
sudo apt-get install libgdal-dev libgdal1h
sudo apt-get install libxerces-c2-dev
sudo apt-get install libfox-1.6-dev
not succesful, following problem occurs
The following packages have unmet dependencies:
libfox-1.6-dev : Depends: libjpeg-dev
Depends: libpng12-dev but it is not going to be installed
Depends: zlib1g-dev but it is not going to be installed
Depends: libtiff4-dev but it is not going to be installed
Depends: libxcursor-dev but it is not going to be installed
Depends: libxft-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
plz find out any solution
This comment has been minimized.
Copy link Quote reply
eugeneYWang commented Mar 7, 2018
Here is my personal experience. On 16.04 LTS with GDAL 2.1.3 from UBUNTUGIS Stable PPA repo, the prerequisite package is only libgdal-dev.
Yes, installing GDAL in a venv is a doozy. Conveniently, I just wrote up the documentation on how to do so for my advisor’s lab! While I am not savvy enough to pinpoint the exact cause of your error, I can give you a bunch of things to try to fix it.
First, ensure you have gdal installed on the host (i.e. not in a venv). I just run the following:
sudo apt-get install libgdal1i libgdal1-dev libgdal-dev
Now run gdal-config —version to get the version that apt-get provided you with. For example I get 1.11.3
Now, the easiest way in my experience to get the python bindings in a venv is using pygdal. The trick is to get the right version! To do so, activate your virtual environment and run
pip install pygdal==1.11.3
but replace the version with whatever you got from gdal-config —version. Note: you may get an error that says
Could not find a version that satisfies the requirement pygdal==1.11.3 (from versions: 1.8.1.0, 1.8.1.1, 1.8.1.2, 1.8.1.3, 1.9.2.0, 1.9.2.1, 1.9.2.3, 1.10.0.0, 1.10.0.1, 1.10.0.3, 1.10.1.0, 1.10.1.1, 1.10.1.3, 1.11.0.0, 1.11.0.1, 1.11.0.3, 1.11.1.0, 1.11.1.1, 1.11.1.3, 1.11.2.1, 1.11.2.3, 1.11.3.3, 1.11.4.3, 2.1.0.3) No matching distribution found for pygdal==1.11.3
If that happens, run the pip install again but with the highest version that still matches. e.g. in this case you would run pip install pygdal==1.11.3.3
.
This comment has been minimized.
Copy link Quote reply
abhijayQuantela commented May 22, 2018
I got the following error:
This comment has been minimized.
Copy link Quote reply
denadai2 commented May 26, 2018
@abhijayQuantela be careful to install the same version you installed in your system
This comment has been minimized.
Copy link Quote reply
abhishekmaroon5 commented Jul 24, 2018
Command «python setup.py egg_info» failed with error code 1 in /tmp/pip-install-unlz6509/gdal/
can someone please help me with this error while using command
pip install gdal==1.11.2 —global-option=build_ext —global-option=»-I/usr/include/gdal/»
This comment has been minimized.
Copy link Quote reply
akshmakov commented Jul 27, 2018 •
However, this can be still done in one line with only pip, The missing link is incorrect include flags for the build step but it seems the —include-dirs alone is not always sufficient.
CFLAGS=»-I /usr/include/gdal» CXXFLAGS=»-I /usr/include/gdal» pip install GDAL==your.system.gdal.version
To determine installed GDAL, simply ask apt apt show gdal-dev and use the same version. Tested with GDAL-2.2.2 in ubuntugis-unstable
This comment has been minimized.
Copy link Quote reply
prhbrt commented Aug 29, 2018
@abhijayQuantela I had the same issue and found this to work
optional: install the newest version of gdal-bin and libgdal-dev :
My gdal version was 2.2.3, so mayve specifically install that one if this does not work.
required: install using pip3:
This comment has been minimized.
Copy link Quote reply
fitoprincipe commented Sep 20, 2018
Thank you @prinsherbert! It was the only solution that worked for me
This comment has been minimized.
Copy link Quote reply
skyfeature commented Sep 24, 2018
Here is my personal experience. On 16.04 LTS with GDAL 2.1.3 from UBUNTUGIS Stable PPA repo, the prerequisite package is only libgdal-dev.
Yes, installing GDAL in a venv is a doozy. Conveniently, I just wrote up the documentation on how to do so for my advisor’s lab! While I am not savvy enough to pinpoint the exact cause of your error, I can give you a bunch of things to try to fix it.
First, ensure you have gdal installed on the host (i.e. not in a venv). I just run the following:
sudo apt-get install libgdal1i libgdal1-dev libgdal-dev
Now run gdal-config —version to get the version that apt-get provided you with. For example I get 1.11.3
Now, the easiest way in my experience to get the python bindings in a venv is using pygdal. The trick is to get the right version! To do so, activate your virtual environment and run
pip install pygdal==1.11.3
but replace the version with whatever you got from gdal-config —version. Note: you may get an error that says
Could not find a version that satisfies the requirement pygdal==1.11.3 (from versions: 1.8.1.0, 1.8.1.1, 1.8.1.2, 1.8.1.3, 1.9.2.0, 1.9.2.1, 1.9.2.3, 1.10.0.0, 1.10.0.1, 1.10.0.3, 1.10.1.0, 1.10.1.1, 1.10.1.3, 1.11.0.0, 1.11.0.1, 1.11.0.3, 1.11.1.0, 1.11.1.1, 1.11.1.3, 1.11.2.1, 1.11.2.3, 1.11.3.3, 1.11.4.3, 2.1.0.3) No matching distribution found for pygdal==1.11.3
If that happens, run the pip install again but with the highest version that still matches. e.g. in this case you would run pip install pygdal==1.11.3.3
.
I can confirm that this is working on ubuntu18.04.
Only change I did was instead of running sudo apt-get install libgdal1i libgdal1-dev libgdal-dev , I only installed libgdal-dev .