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

1.2b2 from wheel can't locate proj.db #2079

Closed
sgillies opened this issue Jan 11, 2021 · 4 comments · Fixed by #2080
Closed

1.2b2 from wheel can't locate proj.db #2079

sgillies opened this issue Jan 11, 2021 · 4 comments · Fixed by #2080
Assignees
Labels
Milestone

Comments

@sgillies
Copy link
Member

sgillies commented Jan 11, 2021

The PROJ search path isn't set properly. I had thought that the tests run by the wheel builder would find such bugs, but no.

$ rio info ~/projects/rasterio/tests/data/RGB.byte.tif 
Traceback (most recent call last):
  File "rasterio/_base.pyx", line 1455, in rasterio._base._osr_from_crs
  File "rasterio/_err.pyx", line 192, in rasterio._err.exc_wrap_int
rasterio._err.CPLE_AppDefinedError: PROJ: proj_create_from_database: cannot build projectedCRS 32618: SQLite error on SELECT extent.description, extent.south_lat, extent.north_lat, extent.west_lon, extent.east_lon, scope.scope, (CASE WHEN scope.scope LIKE '%large scale%' THEN 0 ELSE 1 END) AS score FROM usage JOIN extent ON usage.extent_auth_name = extent.auth_name AND usage.extent_code = extent.code JOIN scope ON usage.scope_auth_name = scope.auth_name AND usage.scope_code = scope.code WHERE object_table_name = ? AND object_auth_name = ? AND object_code = ? ORDER BY score, usage.auth_name, usage.code: no such table: usage

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sean/.local/bin/rio", line 8, in <module>
    sys.exit(main_group())
  File "/home/sean/.local/pipx/venvs/rasterio/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/sean/.local/pipx/venvs/rasterio/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/sean/.local/pipx/venvs/rasterio/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/sean/.local/pipx/venvs/rasterio/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/sean/.local/pipx/venvs/rasterio/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/sean/.local/pipx/venvs/rasterio/lib/python3.7/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/sean/.local/pipx/venvs/rasterio/lib/python3.7/site-packages/rasterio/rio/info.py", line 90, in info
    info['lnglat'] = src.lnglat()
  File "rasterio/_base.pyx", line 986, in rasterio._base.DatasetBase.lnglat
  File "rasterio/_base.pyx", line 1394, in rasterio._base._transform
  File "rasterio/_base.pyx", line 1461, in rasterio._base._osr_from_crs
rasterio.errors.CRSError: PROJ: proj_create_from_database: cannot build projectedCRS 32618: SQLite error on SELECT extent.description, extent.south_lat, extent.north_lat, extent.west_lon, extent.east_lon, scope.scope, (CASE WHEN scope.scope LIKE '%large scale%' THEN 0 ELSE 1 END) AS score FROM usage JOIN extent ON usage.extent_auth_name = extent.auth_name AND usage.extent_code = extent.code JOIN scope ON usage.scope_auth_name = scope.auth_name AND usage.scope_code = scope.code WHERE object_table_name = ? AND object_auth_name = ? AND object_code = ? ORDER BY score, usage.auth_name, usage.code: no such table: usage
@sgillies sgillies added the bug label Jan 11, 2021
@sgillies sgillies added this to the 1.2.0 milestone Jan 11, 2021
@sgillies sgillies self-assigned this Jan 11, 2021
@sgillies
Copy link
Member Author

This looks like the culprit: https://github.com/mapbox/rasterio/blob/master/rasterio/_env.pyx#L372. Older, incompatible PROJ data previously installed on my system is being found and the data in the module is ignored.

@vincentsarago
Copy link
Member

@snowman2
Copy link
Member

Here is the search logic used by pyproj in case it is helpful: docs | code

1. The one set by pyproj.datadir.set_data_dir (if exists & valid)
2. The internal proj directory (if exists & valid)
3. The directory in PROJ_LIB (if exists & valid)
4. The directory on sys.prefix (if exists & valid)
5. The directory on the PATH (if exists & valid)

sgillies pushed a commit that referenced this issue Jan 11, 2021
sgillies pushed a commit that referenced this issue Jan 12, 2021
* Search wheel early

Resolves #2079

* Search wheels early in rasterio.env and add debug logging
@sgillies
Copy link
Member Author

@snowman2 thanks! I think I've got something equivalent in #2080.

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

Successfully merging a pull request may close this issue.

3 participants