You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't know if this is an issue or an expected behaviour, but the configuration file gets executed 3 times:
Documentation:
--config=<Unicode>
Path to an extra config file to load.
If specified, load this config file in addition to any other IPython
config.
Default: ''
Equivalent to: [--BaseIPythonApplication.extra_config_file]
Extra configuration file
# ~/config_folder/extra_config.pyprint("hello")
Execution test
❯ ipython --config=~/config_folder/extra_config.py
hello
hello
hello
Python 3.12.8 | packaged by conda-forge | (main, Dec 5 2024, 14:06:27) [MSC v.1942 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license'for more information
IPython 8.32.0 -- An enhanced Interactive Python. Type '?'for help.
In [1]:
Looks like --config is not intended to be used with absolute paths.
ipython --debug --config /Users/yann/ipython/extra_config.py
[TerminalIPythonApp] Using existing profile dir: '/Users/yann/.ipython/profile_default'
[TerminalIPythonApp] Searching path ['/Users/yann/.ipython/profile_default', '/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.11/etc/ipython', '/usr/local/etc/ipython', '/etc/ipython'] for config files
[TerminalIPythonApp] Attempting to load config file: ipython_config.py
[TerminalIPythonApp] Looking for ipython_config in /etc/ipython
[TerminalIPythonApp] Looking for ipython_config in /usr/local/etc/ipython
[TerminalIPythonApp] Looking for ipython_config in /opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.11/etc/ipython
[TerminalIPythonApp] Looking for ipython_config in /Users/yann/.ipython/profile_default
[TerminalIPythonApp] Loaded config file: /Users/yann/.ipython/profile_default/ipython_config.py
[TerminalIPythonApp] Attempting to load config file: ipython_config.py
[TerminalIPythonApp] Looking for /Users/yann/ipython/extra_config in /etc/ipython
hello
[TerminalIPythonApp] Loaded config file: /Users/yann/ipython/extra_config.py
[TerminalIPythonApp] Looking for /Users/yann/ipython/extra_config in /usr/local/etc/ipython
hello
[TerminalIPythonApp] Loaded config file: /Users/yann/ipython/extra_config.py
[TerminalIPythonApp] Looking for /Users/yann/ipython/extra_config in /opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.11/etc/ipython
hello
[TerminalIPythonApp] Loaded config file: /Users/yann/ipython/extra_config.py
[TerminalIPythonApp] Looking for /Users/yann/ipython/extra_config in /Users/yann/.ipython/profile_default
hello
[TerminalIPythonApp] Loaded config file: /Users/yann/ipython/extra_config.py
Python 3.11.11 (main, Dec 3 2024, 17:20:40) [Clang 16.0.0 (clang-1600.0.26.4)]
Type 'copyright', 'credits' or 'license' for more information
IPython 9.0.0.dev -- An enhanced Interactive Python. Type '?' for help.
[TerminalIPythonApp] Loading IPython extensions...
[TerminalIPythonApp] Loading IPython extension: storemagic
[TerminalIPythonApp] Starting IPython's mainloop...
It looks in four directories but always finds it because of the absolute path. That explains why it's loaded many times (4 times for me on mac)
By moving the config file to one of the expected directories it only loads once.
➜ ipython git:(main) cp extra_config.py /Users/yann/.ipython/profile_default
➜ ipython git:(main) ipython --config extra_config.py
hello
Python 3.11.11 (main, Dec 3 2024, 17:20:40) [Clang 16.0.0 (clang-1600.0.26.4)]
Type 'copyright', 'credits' or 'license' for more information
IPython 9.0.0.dev -- An enhanced Interactive Python. Type '?' for help.
A better solution could be to detect if the path is absolute and only load it once
Activity
Yann-P commentedon Feb 7, 2025
Looks like --config is not intended to be used with absolute paths.
It looks in four directories but always finds it because of the absolute path. That explains why it's loaded many times (4 times for me on mac)
By moving the config file to one of the expected directories it only loads once.
A better solution could be to detect if the path is absolute and only load it once