laike9m / Cyberbrain

Python debugging, redefined.
http://bit.ly/cyberbrain-features
MIT License
2.51k stars 159 forks source link

在VScode中不显示新窗口,报错:asdict() got an unexpected keyword argument 'value_serializer' #97

Closed javacoffer2020 closed 3 years ago

javacoffer2020 commented 3 years ago

Describe the bug 扩展无法在VScode中使用。以非调试模式运行后,无法打开Cyberbrain的调试窗口。

Code to reproduce the bug

"""Make rhyming words"""

import re
import string

from cyberbrain import trace

@trace
def stemmer(word):
    """Return leading consonants (if any), and 'stem' of word"""

    word = word.lower()
    vowels = "aeiou"
    consonants = "".join([c for c in string.ascii_lowercase if c not in vowels])
    pattern = (
        "([" + consonants + "]+)?"  # capture one or more, optional
        "([" + vowels + "])"  # capture at least one vowel
        "(.*)"  # capture zero or more of anything
    )

    match = re.match(pattern, word)
    if match:
        p1 = match.group(1) or ""
        p2 = match.group(2) or ""
        p3 = match.group(3) or ""
        return p1, p2 + p3
    else:
        return word, ""

if __name__ == "__main__":
    stemmer("apple")

Screenshots and/or error messages

PS E:\Jupyter\Jupyter_Lib>  e:; cd 'e:\Jupyter\Jupyter_Lib'; & 'e:\Anaconda\python.exe' 'c:\Users\Denis Shen\.vscode\extensions\ms-python.python-2021.3.658691958\pythonFiles\lib\python\debugpy\launcher' '50801' '--' 'e:\test1.py' 
Traceback (most recent call last):
  File "e:\test1.py", line 33, in <module>
    stemmer("apple")
  File "e:\Anaconda\lib\site-packages\cyberbrain\tracer.py", line 201, in wrapper
    self.stop()
  File "e:\Anaconda\lib\site-packages\cyberbrain\tracer.py", line 151, in stop
    self.rpc_client.send_frame(self.frame)
  File "e:\Anaconda\lib\site-packages\cyberbrain\rpc_client.py", line 107, in send_frame
    value_serializer=event.value_serializer,
TypeError: asdict() got an unexpected keyword argument 'value_serializer'

Environment: Please provide the following information:

laike9m commented 3 years ago

The reason is that you have an old version of attrs installed. Could you try pip show attrs and paste the output?

I don't why it happens because in pyproject.toml, it specifies that attrs needs to be >= 20.0. So maybe uninstall and reinstall cyberbrain will solve this problem.

javacoffer2020 commented 3 years ago

Thank you for your response! I have upgraded attrs to 20.3.0. And now Cyberbrain is worked. Maybe, old version attrs is required by another package, so new version couldn't be auto installed when I pip install cyberbrain (maybe I should use --user when I installed Cyberbrain ). Finally, I upgraded it manually.

laike9m commented 3 years ago

Great! Theoretically it installing cyberbrain should upgrade its dependencies, but since you're using Conda and I'm not very familiar with it, it may happen.