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

Unable to install deepforestr because libgdal is out of date #12

Closed
priyapatel1 opened this issue Jun 25, 2024 · 3 comments
Closed

Unable to install deepforestr because libgdal is out of date #12

priyapatel1 opened this issue Jun 25, 2024 · 3 comments

Comments

@priyapatel1
Copy link

I'm trying to install deepforestr on my computer. I was able to run the following with no issue:

conda create -n deepforest python=3 pytorch torchvision -c pytorch
conda activate deepforest
conda install deepforest -c conda-forge

However, when moving on to the R portion of the installation, I came across an error related to libgdal when trying to install the spatial dependencies:

This is what I ran in my R session:

install.packages('reticulate') # Install R package for interacting with Python
reticulate::install_miniconda() # Install Python

These previous two lines ran fine. THEN, I ran the following:

reticulate::py_install(c('gdal', 'rasterio', 'fiona')) # Install spatial dependencies via conda

This is the error I get:

Using virtual environment '/Users/priyapatel/.virtualenvs/r-reticulate' ...
+ /Users/priyapatel/.virtualenvs/r-reticulate/bin/python -m pip install --upgrade --no-user gdal rasterio fiona
Collecting gdal
  Using cached GDAL-3.9.0.tar.gz (839 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'error'
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [53 lines of output]
      Using numpy 2.0.0
      running egg_info
      writing gdal-utils/GDAL.egg-info/PKG-INFO
      writing dependency_links to gdal-utils/GDAL.egg-info/dependency_links.txt
      writing entry points to gdal-utils/GDAL.egg-info/entry_points.txt
      writing requirements to gdal-utils/GDAL.egg-info/requires.txt
      writing top-level names to gdal-utils/GDAL.egg-info/top_level.txt
      Traceback (most recent call last):
        File "/Users/priyapatel/.virtualenvs/r-reticulate/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/priyapatel/.virtualenvs/r-reticulate/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/Users/priyapatel/.virtualenvs/r-reticulate/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/private/var/folders/rl/sgxmp5k545q93m0wrgmjlssr0000gn/T/pip-build-env-o98cq5q5/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 327, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
        File "/private/var/folders/rl/sgxmp5k545q93m0wrgmjlssr0000gn/T/pip-build-env-o98cq5q5/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 297, in _get_build_requires
          self.run_setup()
        File "/private/var/folders/rl/sgxmp5k545q93m0wrgmjlssr0000gn/T/pip-build-env-o98cq5q5/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 313, in run_setup
          exec(code, locals())
        File "<string>", line 421, in <module>
        File "/private/var/folders/rl/sgxmp5k545q93m0wrgmjlssr0000gn/T/pip-build-env-o98cq5q5/overlay/lib/python3.9/site-packages/setuptools/__init__.py", line 103, in setup
          return distutils.core.setup(**attrs)
        File "/private/var/folders/rl/sgxmp5k545q93m0wrgmjlssr0000gn/T/pip-build-env-o98cq5q5/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 184, in setup
          return run_commands(dist)
        File "/private/var/folders/rl/sgxmp5k545q93m0wrgmjlssr0000gn/T/pip-build-env-o98cq5q5/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 200, in run_commands
          dist.run_commands()
        File "/private/var/folders/rl/sgxmp5k545q93m0wrgmjlssr0000gn/T/pip-build-env-o98cq5q5/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/private/var/folders/rl/sgxmp5k545q93m0wrgmjlssr0000gn/T/pip-build-env-o98cq5q5/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 976, in run_command
          super().run_command(command)
        File "/private/var/folders/rl/sgxmp5k545q93m0wrgmjlssr0000gn/T/pip-build-env-o98cq5q5/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/private/var/folders/rl/sgxmp5k545q93m0wrgmjlssr0000gn/T/pip-build-env-o98cq5q5/overlay/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 321, in run
          self.find_sources()
        File "/private/var/folders/rl/sgxmp5k545q93m0wrgmjlssr0000gn/T/pip-build-env-o98cq5q5/overlay/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 329, in find_sources
          mm.run()
        File "/private/var/folders/rl/sgxmp5k545q93m0wrgmjlssr0000gn/T/pip-build-env-o98cq5q5/overlay/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 550, in run
          self.add_defaults()
        File "/private/var/folders/rl/sgxmp5k545q93m0wrgmjlssr0000gn/T/pip-build-env-o98cq5q5/overlay/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 588, in add_defaults
          sdist.add_defaults(self)
        File "/private/var/folders/rl/sgxmp5k545q93m0wrgmjlssr0000gn/T/pip-build-env-o98cq5q5/overlay/lib/python3.9/site-packages/setuptools/command/sdist.py", line 102, in add_defaults
          super().add_defaults()
        File "/private/var/folders/rl/sgxmp5k545q93m0wrgmjlssr0000gn/T/pip-build-env-o98cq5q5/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/sdist.py", line 250, in add_defaults
          self._add_defaults_ext()
        File "/private/var/folders/rl/sgxmp5k545q93m0wrgmjlssr0000gn/T/pip-build-env-o98cq5q5/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/sdist.py", line 334, in _add_defaults_ext
          build_ext = self.get_finalized_command('build_ext')
        File "/private/var/folders/rl/sgxmp5k545q93m0wrgmjlssr0000gn/T/pip-build-env-o98cq5q5/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 303, in get_finalized_command
          cmd_obj.ensure_finalized()
        File "/private/var/folders/rl/sgxmp5k545q93m0wrgmjlssr0000gn/T/pip-build-env-o98cq5q5/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 111, in ensure_finalized
          self.finalize_options()
        File "<string>", line 276, in finalize_options
      Exception: Python bindings of GDAL 3.9.0 require at least libgdal 3.9.0, but 3.8.4 was found
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
Error: Error installing package(s): 'gdal', 'rasterio', 'fiona'

How do I go about resolving this?

Environment (please complete the following information):

  • OS: MacOS
  • Python version and environment : Python 3.12.2

User Story
I want to create tree canopy datasets across Canada - I'm a research at the University of Toronto School of Public Health.

@ethanwhite
Copy link
Member

Hi @priyapatel1 - thanks for reporting this and for your patience. We've had ongoing issues getting things to work properly on macOS. Checkout #5 for the current status of things. If you have time to work with us on debugging on macOS we'd be happy to work with you on trying to figure it out. If you need to get something up and running quickly then it's pretty easy to do in Python even if you don't much Python work. Let us know which direction you'd like to go and we'll be happy to help.

@ethanwhite
Copy link
Member

Given that you've installed deepforest successfully using conda the first thing we should try is seeing if you can successfully use that conda environment instead of the one you were created from R when the error happened.

1. Look up the path to your the conda environment

conda activate deepforest
which python

2. In R set tell recticulate to use this path

Sys.setenv(RETICULATE_PYTHON = "/path/to/python")

3. Check to see if this worked

library(reticulate)
py_config()

4. If that worked, try running some deepforestr commands

I also think I understand why the error occurred when installing the spatial packages the other way (looks like a change in the reticulate defaults), but the above is the simplest possible fix given where you currently are.

ethanwhite added a commit to ethanwhite/deepforestr that referenced this issue Jul 18, 2024
This avoids virtualenv being selected causing issues with geospatial installs.

Addresses issues like those in weecology#12.
@ethanwhite
Copy link
Member

Closing due to inactivity. Feel free to reopen if you come back to this @priyapatel1

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

No branches or pull requests

2 participants