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.

Any idea why IPython.get_ipython() is returning None?

See original GitHub issue
Traceback (most recent call last):
  File "/Users/kkotari/.pyenv/versions/3.7.4/bin/ipycli", line 8, in <module>
    sys.exit(run())
  File "/Users/kkotari/.pyenv/versions/3.7.4/Python.framework/Versions/3.7/lib/python3.7/site-packages/ipycli/ipycli.py", line 8, in run
    IPython.get_ipython().define_macro('var', """a=10
AttributeError: 'NoneType' object has no attribute 'define_macro'

Repo

I was trying to create a python package where the scripts needs to run on IPython. Is there any special settings to create such a package.

ipython --version 7.14.0

Thanks in advance.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Carreaucommented, Aug 1, 2021

The error I get is as follows: Traceback (most recent call last):

As you probably correctly guessed, this is because get_ipython() only forwas from within IPython sessions.

File “/data/oms/sarah/my_ann_solo/test_score1.py”, line 20 def verify_extension(supported_extensions: List[str], filename: str) -> None: ^ SyntaxError: invalid syntax

Can you check if IPython is not installed for Python 2 ? Or to be more sure to run IPython from Python 3, you can do:

/path/to/python3 -m IPython test_score1.py

If this still does not work, can you open a separate issues, with possibly the content of your files so that we can investigate ?

Thanks.

0reactions
Carreaucommented, Aug 5, 2021

Any memory error like that are really unlikely to happen because of IPython/Python.

Timing with magics is really just a thin wrapper around python’s timeit module so you should be able to time in pure python as well, though you will need to put your code in strings literals.

On Tue, Aug 3, 2021, 16:08 Sarah-2021-scu @.***> wrote:

Thank you for your solution. I was timing the cell in my notebook which was causing the error. On changing that the command is working fine. However I am experiencing another error of “free(): invalid pointer Aborted (core dumped)” after execution. I guess valgrind can generate a report of the analysis but I need to have sudo permission for building the same. I am trying to do it with the build.

Thanks in advance.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ipython/ipython/issues/12334#issuecomment-892224054, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACR5T23PA4TBRILVPL3QN3T3BZHTANCNFSM4NJUKTNA .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can I only use ipython through the jupyter notebook
I have already downloaded the ipython module but from what I have undertand I can only use it through Jupyter ? Which makes...
Read more >
IPython reference — IPython 8.7.0 documentation
If invoked with no options, it executes the file and exits, passing the remaining arguments to the script, just as if you had...
Read more >
DB2 Jupyter Notebook Extensions
There is no concept of a transaction where multiple DML/DDL ... Check if we are running in iPython or Jupyter try: if (get_ipython().config ......
Read more >
Jupyter Notebook Enhancements, Tips And Tricks - fastai
Since I only wanted the nb name, I tweaked it a bit (1) to just return the filename w/o ext (2) throw an...
Read more >
Let's Write an IPython Extension the Hard Way
It's working, but partially. If we assign a variable ( In [4] ) and then reference it ( In [5] ), you will...
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