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.

pysnooper/tracer.py", line 75, in get_source_from_frame raise NotImplementedError

See original GitHub issue

When I ran a simple script:

import pysnooper
import numpy as np

@pysnooper.snoop()
def multi_matmul(times):
    x = np.random.rand(2,2)
    w = np.random.rand(2,2)
    
    for i in range(times):
        x = np.matmul(x,w)
    return x

multi_matmul(3)

The error happened:

Starting var:.. times = 3
Traceback (most recent call last):
  File "<tmp 1>", line 14, in <module>
    multi_matmul(3)
  File "</usr/local/lib/python3.6/dist-packages/decorator.py:decorator-gen-121>", line 2, in multi_matmul
  File "/usr/local/lib/python3.6/dist-packages/pysnooper/pysnooper.py", line 72, in decorate
    return function(*args, **kwargs)
  File "<tmp 1>", line 4, in multi_matmul
    @pysnooper.snoop()
  File "/usr/local/lib/python3.6/dist-packages/pysnooper/tracer.py", line 182, in trace
    source_line = get_source_from_frame(frame)[frame.f_lineno - 1]
  File "/usr/local/lib/python3.6/dist-packages/pysnooper/tracer.py", line 75, in get_source_from_frame
    raise NotImplementedError
NotImplementedError

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:21 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
cool-RRcommented, Apr 23, 2019

Ah, I think I get it. Are you using PySnooper on code that you’re typing in the interactive shell?

0reactions
cool-RRcommented, Apr 25, 2019

I think you forgot to upgrade PySnooper.

On Thu, Apr 25, 2019, 04:31 周文青 notifications@github.com wrote:

OS: Ubuntu 18.04 python:

@cool-RR https://github.com/cool-RR I tried in ipython and qtconsole, it didn’t work. Errors shows below:

Jupyter QtConsole 4.4.3 Python 3.6.8 (default, Jan 14 2019, 11:02:34) Type ‘copyright’, ‘credits’ or ‘license’ for more information IPython 7.4.0 – An enhanced Interactive Python. Type ‘?’ for help.

In [1]: import pysnooper …: …: @pysnooper.snoop() …: def number_to_bits(number): …: if number: …: bits = [] …: while number: …: number, remainder = divmod(number, 2) …: bits.insert(0, remainder) …: return bits …: else: …: return [0] …: …: number_to_bits(6) Starting var:… number = 6

NotImplementedError Traceback (most recent call last) <ipython-input-1-d9086aeb58cb> in <module> 12 return [0] 13 —> 14 number_to_bits(6)

</usr/local/lib/python3.6/dist-packages/decorator.py:decorator-gen-127> in number_to_bits(number)

/usr/local/lib/python3.6/dist-packages/pysnooper/pysnooper.py in decorate(function, *args, **kwargs) 70 write=write, variables=variables, 71 depth=depth, prefix=prefix): —> 72 return function(*args, **kwargs) 73 74 return decorate

<ipython-input-1-d9086aeb58cb> in number_to_bits(number) 1 import pysnooper 2 ----> 3 @pysnooper.snoop() 4 def number_to_bits(number): 5 if number:

/usr/local/lib/python3.6/dist-packages/pysnooper/tracer.py in trace(self, frame, event, arg) 180 181 now_string = datetime_module.datetime.now().time().isoformat() –> 182 source_line = get_source_from_frame(frame)[frame.f_lineno - 1] 183 self.write('{indent}{now_string} {event:9} ’ 184 ‘{frame.f_lineno:4} {source_line}’.format(**locals()))

/usr/local/lib/python3.6/dist-packages/pysnooper/tracer.py in get_source_from_frame(frame) 73 pass 74 if source is None: —> 75 raise NotImplementedError 76 77 # If we just read the source from a file, or if the loader did not

NotImplementedError:

In [2]:

And about the first problem, I ran the code in pyzo and didn’t save the file before. When I saved the file it worked. It’s strange!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cool-RR/PySnooper/issues/20#issuecomment-486485766, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAN3SSVYR6TKAPSSB2SCJDPSECVZANCNFSM4HHVII3A .

Read more comments on GitHub >

github_iconTop Results From Across the Web

When to use 'raise NotImplementedError'? - Stack Overflow
As the documentation states,. In user defined base classes, abstract methods should raise this exception when they require derived classes ...
Read more >
NotImplementedError() raised while trying apply #3555 - GitHub
which I want to merge using dask. So, I am reading each file in a for-loop --> storing them as dask dataframe -->...
Read more >
Python Exception Handling – NotImplementedError
Struggling with a NotImplementedError in your code? In this blog, we'll go over what it is, how to raise it, and how to...
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