# RuntimeError: PROJ: proj\_create\_from\_database

**URL:** <https://openradar.discourse.group/t/runtimeerror-proj-proj-create-from-database/434>\
**Category:** Python\
**Created:** [March 22, 2024, 9:09am UTC](https://openradar.discourse.group/t/runtimeerror-proj-proj-create-from-database/434 "2024-03-22T09:09:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jorahu](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/jorahu/32/19_2.png) [@jorahu](https://openradar.discourse.group/u/jorahu)\
**Post date:** [March 22, 2024, 9:09am UTC](https://openradar.discourse.group/t/runtimeerror-proj-proj-create-from-database/434/1 "2024-03-22T09:09:41Z")

</div>

I am testing simple data reading, but getting error during georeferencing with PROJ variable:  
RuntimeError: PROJ: proj\_create\_from\_database

```auto
vol = xd.io.open_odim_datatree(fpath)

swp = vol["sweep_0"].ds
swp = swp.assign_coords(sweep_mode=swp.sweep_mode)
swp = swp.wrl.georef.georeference()

```

I probably have to export some PATH-s for my conda environment, but I am totally out of clue what I have to do specifically. Maybe anyone have more recent experience how to solve it. Thanks!  
Wradlib version 2.0.3.

---

<div class="post-metadata">

**Author:** ![jorahu](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/jorahu/32/19_2.png) [@jorahu](https://openradar.discourse.group/u/jorahu)\
**Post date:** [March 22, 2024, 9:21am UTC](https://openradar.discourse.group/t/runtimeerror-proj-proj-create-from-database/434/2 "2024-03-22T09:21:18Z")

</div>

Alright, found something.  
Added the following path to the env proj.db file.

```auto
import os
os.environ['PROJ_LIB'] = '/home/jorma/anaconda3/envs/steps4/share/proj'

```

If anyone can add how to put this export to bashrc, I would still be interested in that.

---

<div class="post-metadata">

**Author:** ![kmuehlbauer](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/kmuehlbauer/32/439_2.png) [@kmuehlbauer](https://openradar.discourse.group/u/kmuehlbauer)\
**Post date:** [March 22, 2024, 11:11am UTC](https://openradar.discourse.group/t/runtimeerror-proj-proj-create-from-database/434/3 "2024-03-22T11:11:37Z")

</div>

@jorahu Unfortunately I do not have a better advise. I get this type of error every once in a while, but can’t exactly pinpoint the source. I

I’m thinking something is fishy with the PROJ/GDAL conda-env vars. Those might not get set, if the conda environment is not correctly activate. This happens if you just run the python kernel via some IDE or the like. You might check which environment variables are set in the environment after activation.

I have these set in the env after activation:

```bash
$ env

```

```bash
GDAL_DATA=/home/kai/data/mambaforge/envs/xr_312/share/gdal
PROJ_NETWORK=ON
PROJ_DATA=/home/kai/data/mambaforge/envs/xr_312/share/proj

```

```python
>>> pyproj.show_versions()

```

```python
pyproj info:
    pyproj: 3.6.1
      PROJ: 9.3.1
  data dir: /home/kai/data/mambaforge/envs/xr_312/share/proj
user_data_dir: /user/k.muehlbauer/.local/share/proj
PROJ DATA (recommended version): 1.16
PROJ Database: 1.2
EPSG Database: v10.098 [2023-11-24]
ESRI Database: ArcGIS Pro 3.2 [2023-11-02]
IGNF Database: 3.1.0 [2019-05-24]

System:
    python: 3.12.1 | packaged by conda-forge | (main, Dec 23 2023, 08:03:24) [GCC 12.3.0]
executable: /home/kai/data/mambaforge/envs/xr_312/bin/python
   machine: Linux-5.14.21-150500.55.19-default-x86_64-with-glibc2.31

Python deps:
   certifi: 2024.2.2
    Cython: 3.0.7
setuptools: 69.0.3
       pip: 23.3.2

```

HTH,  
Kai

---

<div class="post-metadata">

**Author:** ![jorahu](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/jorahu/32/19_2.png) [@jorahu](https://openradar.discourse.group/u/jorahu)\
**Post date:** [March 22, 2024, 12:40pm UTC](https://openradar.discourse.group/t/runtimeerror-proj-proj-create-from-database/434/4 "2024-03-22T12:40:48Z")

</div>

Thanks Kai! This has been really helpful actually.

The problem is really how I have set up my envs within Jupyterlab. When I activate env and use the “env” command I could also see the GDAL\_DATA and PROJ\_DATA but not PROJ\_LIB that caused the error.  
The following would set the PROJ\_LIB permanently to the env:  
`conda env config vars set PROJ_LIB='/home/jorma/anaconda3/envs/steps4/share/proj' -n steps4`

But… I have installed all the envs to Jupyterlab with ipykernel, and when I run “env” from some notebook with the same env, a lot of environment variables are missing, including both GDAL\_DATA and PROJ\_DATA, not to mentions PROJ\_LIB.

Only when I manually change the variables through os.environ then the variables are added to the env.

```auto
import os
os.environ['PROJ_LIB'] = '/home/jorma/anaconda3/envs/steps4/share/proj'

```

This turned out to be much more complicated than I would have hoped… Need to look into installing the envs to jupyterlab with ipykernel so that it would grab all the environment variables in the process.

Thanks again, Kai!

---

<div class="post-metadata">

**Author:** ![kmuehlbauer](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/kmuehlbauer/32/439_2.png) [@kmuehlbauer](https://openradar.discourse.group/u/kmuehlbauer)\
**Post date:** [March 22, 2024, 1:29pm UTC](https://openradar.discourse.group/t/runtimeerror-proj-proj-create-from-database/434/5 "2024-03-22T13:29:03Z")

</div>

@jorahu Thanks for your response which made me dig a bit deeper now.

I’ve tried the following:

1. create environment for hosting `jupyterlab` and install `nb_conda-kernels` (need python=3.10 until upgraded)

2. create new working environment with specific packages and install `ipykernel`/`ipywidgets`

3. activate `jupyterlab` and run

Now all available conda environments (which have `ipykernel` installed) are available from jupyterlab (in jupyterlab environment). And (big point) the environments will be properly activated. Could you please check, if this works for you too?

Thanks,  
Kai

Links:

> **[GitHub - Anaconda-Platform/nb\_conda\_kernels: Package for managing conda...](https://github.com/Anaconda-Platform/nb_conda_kernels)**
>
> Package for managing conda environment-based kernels inside of Jupyter - Anaconda-Platform/nb\_conda\_kernels

---

<div class="post-metadata">

**Author:** ![jorahu](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/jorahu/32/19_2.png) [@jorahu](https://openradar.discourse.group/u/jorahu)\
**Post date:** [March 22, 2024, 2:32pm UTC](https://openradar.discourse.group/t/runtimeerror-proj-proj-create-from-database/434/6 "2024-03-22T14:32:03Z")

</div>

I am hosting jupyterlab from base, so all I had to do was install nb\_conda\_kernels to base. I had ipykernel installed in all other envs. And now totally different options appeared with kernel selection:  
 ![image](https://global.discourse-cdn.com/free1/uploads/openradar/original/1X/195ad8c9d94af2a2b37f0230d6f53ddc2738ea01.png)

And now, yes, the environment variables are all included → the env is now “correctly” activated within jupyterlab.

I have always looked away from nb\_conda\_kernels for some reason… never knew what it did. But apparently it is more than important. In short, the env hosting jupyterlab (can be base) needs nb\_conda\_kernels installed and all other envs need ipykernel installed.

Thanks a lot, Kai, for looking into it and solving the issue for me! Not wradlib related but rather how my Jupyterlab was set up.

---

<div class="post-metadata">

**Author:** ![kmuehlbauer](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/kmuehlbauer/32/439_2.png) [@kmuehlbauer](https://openradar.discourse.group/u/kmuehlbauer)\
**Post date:** [March 22, 2024, 2:38pm UTC](https://openradar.discourse.group/t/runtimeerror-proj-proj-create-from-database/434/7 "2024-03-22T14:38:12Z")

</div>

Great it works for you too @jorahu. I’ve just stumbled across `nb_conda_kernels` by accident and it will help a lot here too.

As of now I’ve always installed “EVERYTHING” 🤦‍♂️ in my environments 😂 Now, I have one dedicated jupyter env. Sigh 😇

Best,  
Kai

---

<div class="post-metadata">

**Author:** ![jorahu](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/jorahu/32/19_2.png) [@jorahu](https://openradar.discourse.group/u/jorahu)\
**Post date:** [March 22, 2024, 2:40pm UTC](https://openradar.discourse.group/t/runtimeerror-proj-proj-create-from-database/434/8 "2024-03-22T14:40:48Z")

</div>

Will attach this [link](https://stackoverflow.com/questions/53004311/how-to-add-conda-environment-to-jupyter-lab/58198701#58198701) here. Need to use the accepted solution, not the one with most upvotes.

As Jupyterlab is fairly popular IDE, maybe someone else also find the additional envs setup useful.
