Skip to content
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

Deepforest installation fail : A GDAL API version must be specified. #2

Closed
PPierre22 opened this issue Oct 4, 2021 · 7 comments · Fixed by #3
Closed

Deepforest installation fail : A GDAL API version must be specified. #2

PPierre22 opened this issue Oct 4, 2021 · 7 comments · Fixed by #3

Comments

@PPierre22
Copy link

Hi,

When i attempt to install Deepforest using :

reticulate::py_install('DeepForest', pip=TRUE) # Install the Python retriever package

the following error message is repeated many times, and the installation fails :

INFO:root:Building on Windows requires extra options to setup.py to locate needed GDAL files. More information is available in the README.
ERROR: A GDAL API version must be specified. Provide a path to gdal-config using a GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable.

I tried changing the conda environment to make sure it correspond to the one generated by "reticulate::install_miniconda() " using "use_condaenv()" but it does not seem to be the issue.

I also re-installed GDAL via the Anaconda prompt using "conda install -c conda-forge gdal", restarded the computer, re-installed rgdal (from source), restarted R, did not change a thing.

Any idea what may be the issue?

Hereafter a few info on my system:

> sessionInfo()
_R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] forcats_0.5.0 stringr_1.4.0 dplyr_1.0.2 purrr_0.3.4 readr_1.4.0 tidyr_1.1.2 tibble_3.0.4 ggplot2_3.3.2 tidyverse_1.3.0
[10] reticulate_1.22 rgdal_1.5-27 sp_1.4-4

loaded via a namespace (and not attached):
[1] tidyselect_1.1.0 haven_2.3.1 lattice_0.20-41 colorspace_2.0-0 vctrs_0.3.5 generics_0.1.0 rlang_0.4.8 pillar_1.4.7
[9] glue_1.4.2 withr_2.3.0 DBI_1.1.0 rappdirs_0.3.1 dbplyr_2.0.0 modelr_0.1.8 readxl_1.3.1 lifecycle_0.2.0
[17] munsell_0.5.0 gtable_0.3.0 cellranger_1.1.0 rvest_0.3.6 fansi_0.4.1 broom_0.7.2 Rcpp_1.0.7 scales_1.1.1
[25] backports_1.2.0 jsonlite_1.7.1 fs_1.5.0 hms_0.5.3 png_0.1-7 stringi_1.5.3 grid_4.0.3 rprojroot_2.0.2
[33] here_1.0.0 cli_2.2.0 tools_4.0.3 magrittr_2.0.1 crayon_1.3.4 pkgconfig_2.0.3 ellipsis_0.3.1 Matrix_1.2-18
[41] xml2_1.3.2 reprex_0.3.0 lubridate_1.7.9.2 assertthat_0.2.1 httr_1.4.2 rstudioapi_0.13 R6_2.5.0 compiler_4.0.3_

> py_config()
python: C:/Users/.../AppData/Local/r-miniconda/envs/r-reticulate/python.exe
libpython: C:/Users/.../AppData/Local/r-miniconda/envs/r-reticulate/python36.dll
pythonhome: C:/Users/.../AppData/Local/r-miniconda/envs/r-reticulate
version: 3.6.13 (default, Sep 23 2021, 07:38:49) [MSC v.1916 64 bit (AMD64)]
Architecture: 64bit
numpy: C:/Users/.../AppData/Local/r-miniconda/envs/r-reticulate/Lib/site-packages/numpy
numpy_version: 1.19.5

@henrykironde
Copy link
Contributor

Thanks @PPierre22 for reporting this issue, let me try to locate the problem. At the moment, could you try some of these checks
use_condaenv("r-reticulate")
or
make sure that your PATH Environment variable has the paths "C:/Users/.../AppData/Local/r-miniconda/envs/r-reticulate" and C:/Users/.../AppData/Local/r-miniconda/envs/r-reticulate/ {path to site packages}

@PPierre22
Copy link
Author

Thank you @henrykironde for your prompt reply.

Check 1 : use_condaenv("r-reticulate")

FYI, I have 2 conda environments:

conda_list()
name python
1 r-miniconda C:\Users\...\AppData\Local\r-miniconda\python.exe
2 r-reticulate C:\Users\...\AppData\Local\r-miniconda\envs\r-reticulate\python.exe

Using the second one with use_condaenv("r-reticulate") do not change the problem.

Check 2 : make sure that your PATH Environment variable has the paths "C:/Users/.../AppData/Local/r-miniconda/envs/r-reticulate" and C:/Users/.../AppData/Local/r-miniconda/envs/r-reticulate/ {path to site packages}

My current paths are :

> Sys.getenv("PATH")
[1] "C:\Users\...\AppData\Local\r-miniconda\envs\r-reticulate;C:\Users\...\AppData\Local\r-miniconda\envs\r-reticulate\Scripts;C:\Users\...\AppData\Local\r-miniconda\envs\r-reticulate\Library\bin;C:\Program Files\R\R-4.0.3\bin\x64;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\windows\system32;C:\windows\SysWOW64\Empirum;C:\Users\...\AppData\Local\Microsoft\WindowsApps"

I figure the second path you mention is not here, but I’m not sure how to interpret what you mean by “{path to site packages}”. In any cases, I added the following path:

C:\Users\…\AppData\Local\r-miniconda\envs\r-reticulate\Lib\site-packages;

It did not solve the problem. Also, I think that R already found this path, since each time I try to re-install DeepForest it does mention this path:

> reticulate::py_install('DeepForest', pip=TRUE) # Install the Python retriever package
Collecting DeepForest
Using cached deepforest-1.1.2-py3-none-any.whl (20.0 MB)
Collecting xmltodict
Using cached xmltodict-0.12.0-py2.py3-none-any.whl (9.2 kB)
Collecting geopandas
Using cached geopandas-0.9.0-py2.py3-none-any.whl (994 kB)
Requirement already satisfied: pandas in c:\users...\appdata\local\r-miniconda\envs\r-reticulate\lib\site-packages (from DeepForest) (1.1.5)

@ethanwhite
Copy link
Member

ethanwhite commented Oct 4, 2021

I can replicate the issue (sorry @PPierre22 we haven't been testing on Windows yet). I believe the following change will properly install on Windows (as long as RTools is installed):

install.packages('reticulate') # Install R package for interacting with Python
reticulate::install_miniconda() # Install Python
reticulate::py_install(c('gdal', 'rasterio', 'fiona')) # Install spatial dependencies via conda
reticulate::py_install('DeepForest', pip=TRUE) # Install the Python retriever package
devtools::install_github('weecology/deepforestr') # Install the R package for running the retriever

@PPierre22 - can you see if this fixes things for you?

@henrykironde - you're probably onto this already, but it's a problem with getting gdal easily installed on Windows (never fun as you know) since we can't currently get the Python deepforest package to install from conda due to those upstream version issues with pytorch on conda-forge. This approach installs all of the key spatial packages via conda before installing deepforest via pip. This doesn't appear to break any of the top-level functionality. The better long-term solution is getting a full conda based install of deepforest working.

@PPierre22
Copy link
Author

Hi @ethanwhite,
Thanks, your trick did fix my problem! The install of DeepForest went smoothly.
I thought i was out of the wood, and was bold enough to try to install deepforestr, which returned "package ‘deepforestr’ is not available for this version of R" :D so... i'm going to update R & Rstudio, and start again...

@ethanwhite
Copy link
Member

ethanwhite commented Oct 4, 2021

It's not on CRAN yet, that was a typo in the original instructions. If you use the last line in the code block above you should be able to install it straight from the repository as long as you have RTools installed.

@PPierre22
Copy link
Author

The install worked - thanks!

@ethanwhite
Copy link
Member

Awesome! We're still very much in the early development phase here so definitely let us know if you run into more issues as you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants