# Ipython config inside jupyterhub\_config.py

**URL:** <https://discourse.jupyter.org/t/ipython-config-inside-jupyterhub-config-py/25342>\
**Category:** JupyterHub\
**Tags:** ipython\
**Created:** [April 24, 2024, 3:37pm UTC](https://discourse.jupyter.org/t/ipython-config-inside-jupyterhub-config-py/25342 "2024-04-24T15:37:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![svenhaile](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@svenhaile](https://discourse.jupyter.org/u/svenhaile)\
**Post date:** [April 24, 2024, 3:37pm UTC](https://discourse.jupyter.org/t/ipython-config-inside-jupyterhub-config-py/25342/1 "2024-04-24T15:37:39Z")

</div>

Hello, Our JupyterHub 4.1.5 works very well with a few extensions enabled. I am having difficulties in offering system-wide extension configuration settings via `ipython` to users.

### ipython\_config

I have tried placing `ipython_config.json` in many different /etc/ and /usr/ directories mentioned in the official documentation and also directly in /profile\_default/ to no avail. I have operated with `$ipython create profile` which produces a config file but most settings are inactive (commented).

I some cases the user’s Terminal command `$ ipython locate` returns a JSON empty value error in line 1 char 1, even though the file was manually and automatically verified in several ways. But the command always return the correct value `profile_default`.

### jupyterhub\_config.py

I have also tried in `jupyterhub_config.py` to work with this setting to no effect,  
`c.BaseIPythonApplication.extra_config_file = '/opt/conda/envs/jupyterhub/etc/jupyterhub/ipython_config.json'`

We want to control certain default settings like alerts and initial presentation and activate autoclosingbrackets and autocomplete. Here is a sample that could serve to help me understand how to write the syntax of ipython configurations to `jupyterhub_config.py`

```json
// from the file 
// ~/.jupyter/lab/user-settings/@jupyterlab/apputils-extension/themes/jupyterlab-settings
{
  "adaptive-theme": true
}

// Other format
{
  "@jupyterlab/apputils-extension:themes": {
      "adaptive-theme": true
},

```

I have studied several documents and commentaries including [https://ipython.readthedocs.io/en/8.23.0/config/intro.html#setting-configurable-options](https://ipython.readthedocs.io/en/8.23.0/config/intro.html#setting-configurable-options)

Using the approach mentioned there and applying it to the above sample. Would this following statement be a valid translation for use in `jupyterhub_config.py`?  
  
`c.LabApp.apputils-extension.themes.adaptive-theme = True`

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [April 24, 2024, 5:44pm UTC](https://discourse.jupyter.org/t/ipython-config-inside-jupyterhub-config-py/25342/2 "2024-04-24T17:44:36Z")

</div>

`jupyterhub_config.py` is only for the hub component. singleuser servers run in their own environment with their own configuration files.

JupyterLab/Notebook configuration typically needs to go into one of the paths listed when you run `jupyter --paths` in your singleuser server. It’s possible you’ve got multiple Python environments with Jupyter/IPython, so make sure you use the right one.

I’m not sure about IPython, but maybe someone else can chime in?

---

<div class="post-metadata">

**Author:** ![svenhaile](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@svenhaile](https://discourse.jupyter.org/u/svenhaile)\
**Post date:** [April 24, 2024, 6:00pm UTC](https://discourse.jupyter.org/t/ipython-config-inside-jupyterhub-config-py/25342/3 "2024-04-24T18:00:55Z")

</div>

Thanks @manics . Jupyter paths is pointing to `/opt/conda/envs/jupyterhub/etc/jupyter/` among other. It contains potentially applicable `json` config files. I am using this to explore further.

Configuration

- `rhea`, `sudospawner`, `conda`
- batch created `~/.ipython/profile_default/` for use by all ipython kernels

---

<div class="post-metadata">

**Author:** ![svenhaile](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@svenhaile](https://discourse.jupyter.org/u/svenhaile)\
**Post date:** [April 29, 2024, 6:30pm UTC](https://discourse.jupyter.org/t/ipython-config-inside-jupyterhub-config-py/25342/5 "2024-04-29T18:30:11Z")

</div>

IPython 8.22.2

From the Terminal or inside a user’s Jupyter cell, `!ipython --debug --show-config` builds a dynamic output. It confirms that

1. The scripts inside `~/.ipython/personal_default/startup/` are executed
2. The config file `/opt/conda/envs/jupyterhub/etc/ipython/ipython_config.py` is loaded by default (if available there or in a number of other locations)

One ‘extra’ config file like `.json` can be loaded with `ipython_config.py` if one uses in `jupyterhub_config.py` this setting  
`c.BaseIPythonApplication.extra_config_file = '/path/to/ipython_config.json'`

When a user executes `ipython init` resp. `ipython profile create`, the `ipython_kernel_config.py` file is created but it was not loaded in tests.

A problem loading extension configurations in the `ipython_config` files occurs still when using Python 3.11, even if the `kernel` was configured with` "-X", "frozen_modules=off"`:

```auto
[TerminalIPythonApp] WARNING | Error in loading extension: ...
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1140, in _find_and_load_unlocked
ModuleNotFoundError: No module named ... 

```

Possible solution: downgrading to Python 3.10

---

<div class="post-metadata">

**Author:** ![svenhaile](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@svenhaile](https://discourse.jupyter.org/u/svenhaile)\
**Post date:** [May 8, 2024, 8:50pm UTC](https://discourse.jupyter.org/t/ipython-config-inside-jupyterhub-config-py/25342/6 "2024-05-08T20:50:12Z")

</div>

The error loading an extension was caused because I used a wrong description. The solution was to use a naming of the jupyterlab extension that was different than any name mentioned in the output of `jupyter labextension list`
