CRSError is raised when other package is imported first
See original GitHub issueCode Sample, a copy-pastable example if possible
Install dependencies: pip install -U probstructs==0.2.6 pyproj==3.0.0.post1
from probstructs import ExponentialCountMinSketch
from pyproj import CRS
print(repr(CRS("ESRI:54009")))
ec = ExponentialCountMinSketch(10, 10, 10)
ec.inc("A", 1, 1)
print(ec.get("A", 1, 1))
Problem description
When code fromabove is executed it fails with following error:
Traceback (most recent call last):
File "crs_init.py", line 4, in <module>
print(repr(CRS("ESRI:54009")))
File "/usr/local/lib/python3.8/site-packages/pyproj/crs/crs.py", line 296, in __init__
super().__init__(projstring)
File "pyproj/_crs.pyx", line 2302, in pyproj._crs._CRS.__init__
pyproj.exceptions.CRSError: Invalid projection: ESRI:54009: (Internal Proj Error: proj_create: cannot build projectedCRS 54009: buildUnit: non double value)
Expected Output
When imports are swapped:
from pyproj import CRS
from probstructs import ExponentialCountMinSketch
print(repr(CRS("ESRI:54009")))
ec = ExponentialCountMinSketch(10, 10, 10)
ec.inc("A", 1, 1)
print(ec.get("A", 1, 1))
Then expected output is produced:
<Projected CRS: ESRI:54009>
Name: World_Mollweide
Axis Info [cartesian]:
- E[east]: Easting (metre)
- N[north]: Northing (metre)
Area of Use:
- name: World.
- bounds: (-180.0, -90.0, 180.0, 90.0)
Coordinate Operation:
- name: World_Mollweide
- method: Mollweide
Datum: World Geodetic System 1984
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich
1
Minimal Example In Docker
Minimal example could be also run in docker. Please, extract the following archive and run ./docker-run.sh
.
Environment Information
- Output from:
pyproj -v
pyproj info:
pyproj: 3.0.0.post1
PROJ: 7.2.0
data dir: /home/martin/.conda/envs/bd-web/lib/python3.8/site-packages/pyproj/proj_dir/share/proj
user_data_dir: /home/martin/.local/share/proj
System:
python: 3.8.5 | packaged by conda-forge | (default, Sep 16 2020, 18:01:20) [GCC 7.5.0]
executable: /home/martin/.conda/envs/bd-web/bin/python
machine: Linux-5.4.72-microsoft-standard-WSL2-x86_64-with-glibc2.10
Python deps:
/home/martin/.local/lib/python3.8/site-packages/_distutils_hack/__init__.py:30: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
pip: 21.0.1
setuptools: 50.0.0
Cython: None
- Output from:
python -m pyproj -v
pyproj info:
pyproj: 3.0.0.post1
PROJ: 7.2.0
data dir: /home/martin/.conda/envs/bd-web/lib/python3.8/site-packages/pyproj/proj_dir/share/proj
user_data_dir: /home/martin/.local/share/proj
System:
python: 3.8.5 | packaged by conda-forge | (default, Sep 16 2020, 18:01:20) [GCC 7.5.0]
executable: /home/martin/.conda/envs/bd-web/bin/python
machine: Linux-5.4.72-microsoft-standard-WSL2-x86_64-with-glibc2.10
Python deps:
/home/martin/.local/lib/python3.8/site-packages/_distutils_hack/__init__.py:30: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
pip: 21.0.1
setuptools: 50.0.0
Cython: None
- Python version (
python -c "import sys; print(sys.version.replace('\n', ' '))"
)
3.8.5 | packaged by conda-forge | (default, Sep 16 2020, 18:01:20) [GCC 7.5.0]
- Operation System Information (
python -c "import platform; print(platform.platform())"
)
Linux-5.4.72-microsoft-standard-WSL2-x86_64-with-glibc2.10
Installation method
- conda
Conda environment information (if you installed with conda):
Environment (conda list
):
$ conda list proj
conda list proj
# packages in environment at /home/martin/.conda/envs/bd-web:
#
# Name Version Build Channel
proj 7.1.0 h966b41f_1 conda-forge
pyproj 3.0.0.post1 pypi_0 pypi
Details about
conda
and system ( conda info
):
active environment : bd-web
active env location : /home/martin/.conda/envs/bd-web
shell level : 2
user config file : /home/martin/.condarc
populated config files :
conda version : 4.8.3
conda-build version : not installed
python version : 3.8.3.final.0
virtual packages : __glibc=2.23
base environment : /home/martin/miniconda3 (read only)
channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/linux-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /home/martin/miniconda3/pkgs
/home/martin/.conda/pkgs
envs directories : /home/martin/.conda/envs
/home/martin/miniconda3/envs
platform : linux-64
user-agent : conda/4.8.3 requests/2.23.0 CPython/3.8.3 Linux/5.4.72-microsoft-standard-WSL2 ubuntu/16.04.3 glibc/2.23
UID:GID : 1000:1000
netrc file : None
offline mode : False
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Unable to rasterize polygons in rasterio due to CRSError
I want to create a raster for each borough. This means that the first raster would just be Manhattan rasterized, as if it...
Read more >beyond top level package error in relative import
If the module's name does not contain any package information (e.g. it is set to 'main') then relative imports are resolved as if...
Read more >rasterio Documentation
All other Rasterio functions with a transform argument now raise ... packages, choose exactly one of import osgeo.gdal or import rasterio.
Read more >5. The import system — Python 3.11.1 documentation
When a module is first imported, Python searches for the module and if found, ... Or put another way, packages are just a...
Read more >attempted relative import with no known parent package
ImportError — what does that even mean!? I just wanted to import another file. What even is a parent package!? If you are...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello,
I have the same issue with the pulsar-client library using Python>=3.9. It works fine with python 3.8
When I import pulsar first, I have the exact same issue with pyproj. If I import pulsar first, I have a bug in pyproj when I try to do this for example:
So there seems to be some kind of conflict between cpp libraries (since pulsar is also a wrapper for their cpp library) and python 3.9+
Would really appreciate someone looking into this.
I also posted this as an Apache Pulsar Issue: here
For what it’s worth, I’m getting a very similar issue, but have not narrowed down the package that is interfering. If I try a pyproj import on it’s own, it works fine, but when i use it within our app, it fails on the SQLLite CRS query:
crs = pyproj.CRS(proj_string)
pyproj.exceptions.CRSError: Invalid projection: epsg:32631: (Internal Proj Error: proj_create: SQLite error on SELECT auth_name FROM authority_list: disk I/O error)
Have not found a minimal reproducible example yet, but will update once I do.
edit: updated to Pyproj 3.2.1 and issue still there.
edit 2: Issue not there when downgrading to 3.1.0. I don’t know if that means this is a separate issue, if so, apologies for the confusion.