question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

get_ipython returns None when called from startup file

See original GitHub issue

I’m following the instructions given here. Nevertheless, and despite https://github.com/ipython/ipython/issues/9791 and https://github.com/ipython/ipython/pull/9818:

i. get_ipython is not exposed as a builtin. ii. Even when imported as described in the documentation, get_ipython() returns None.

The startup file is just profile_default/ipython_config.py.

I’m testing this agaist the latest revision:

ipython --version
6.2.0.dev

git log
commit 3a7e880c793ab1477c2180376a4bd98651febc03 (HEAD -> master, upstream/master, upstream/HEAD)
Merge: ebb001ec4 6d2b31146
Author: Matthias Bussonnier <bussonniermatthias@gmail.com>
Date:   Mon Jun 12 08:18:57 2017 -0700

    Merge pull request #10655 from adityausathe/master
    
    Feature req #10556: %timeit could use local scope

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
takluyvercommented, Jun 13, 2017

The startup file is just profile_default/ipython_config.py.

That’s not a startup file! See the section Startup files here:

http://ipython.readthedocs.io/en/stable/interactive/tutorial.html#startup-files

0reactions
kirankotaricommented, Jun 13, 2020

@memeplex do you have any sample code. I am facing the same problem, but couldn’t able to get your conversation about reading the config file @takluyver

def initialize(self):
    if ipy.get_ipython() is None:
        self._create_profile() #  passing command to subprocess to create a profile
    print(f'ipython profile: {ipy.get_ipython()}') # still I am getting None
⋊> ~/c/i/i/ipycli on master ⨯ ipython profile create
[ProfileCreate] Generating default config file: '/Users/xyz/.ipython/profile_default/ipython_config.py'
[ProfileCreate] Generating default config file: '/Users/xyz/.ipython/profile_default/ipython_kernel_config.py'
⋊> ~/c/i/i/ipycli on master ⨯

do I need to change any config under ipython_config.py, my objective is to define_macro in ipython

Read more comments on GitHub >

github_iconTop Results From Across the Web

`get_ipython' doesn't work in a startup script for IPython ...
This is an incomplete suggestion -- but if get_ipython isn't in the namespace yet, you can try importing it directly:
Read more >
Module: core.interactiveshell — IPython 8.7.0 documentation
Find and return a magic of the given type by name. Returns None if the magic isn't found. find_user_code(target, ...
Read more >
Python Examples of IPython.get_ipython - ProgramCreek.com
The following are 30 code examples of IPython.get_ipython(). ... import IPython.display if IPython.get_ipython() is not None: def obj_to_dict(obj): return ...
Read more >
Plain diff - Demokritos
from IPython.kernel.zmq.kernelapp import launch_new_instance - return ... the right call via the component system -from IPython import get_ipython - -from ...
Read more >
1.0 Series — IPython 3.2.1 documentation
IPython.embed() is used for embedding IPython into the calling namespace, ... def get_ipython(): """return IPython instance if there is one, None ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found