uriyyo / pycharm-evaluate-async-code

Finally, you can use await in evaluate expression 💪
https://plugins.jetbrains.com/plugin/14476-evaluate-async-code
44 stars 2 forks source link

After installing this plug-in, running the following code in debug mode will report an error #30

Closed wordhui closed 2 years ago

wordhui commented 3 years ago

After installing the plug-in, the following error will appear when running the following code in debug mode: --> attributeerror: 'playwrightcontextmanager' object has no attribute '_ playwright'

The complete code is as follows

from playwright.sync_api import sync_playwright

"""
The following code can run successfully, but after installing this plug-in, pycharm cannot run the following code in debug mode. Pycharm without this plug-in can run the following code successfully in debug mode
"""
playwright_context_manager = sync_playwright()
playwright = playwright_context_manager.start()  # Run in debug mode, there will be an error here
browser = playwright.chromium.launch(headless=False)
context = browser.new_context(ignore_https_errors=True)
page = context.new_page()
page.goto("http://playwright.dev")
print(page.title())
browser.close()

The complete error report is as follows

D:\App\Minconda\envs\py38\python.exe C:\Users\**\AppData\Roaming\JetBrains\PyCharm2020.3\plugins\evaluate-async-code\_pydevd_async_debug.py "D:\App\PyCharm 2020.3.5\plugins\python\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 64914 --file D:/workspace/BaoBao/playwright_t.py
Connected to pydev debugger (build 203.7717.81)

Traceback (most recent call last):
  File "D:\App\PyCharm 2020.3.5\plugins\python\helpers\pydev\pydevd.py", line 1477, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "D:\App\PyCharm 2020.3.5\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "D:/workspace/BaoBao/playwright_t.py", line 4, in <module>
    playwright = playwright_context_manager.start()
  File "D:\App\Minconda\envs\py38\lib\site-packages\playwright\sync_api\_context_manager.py", line 75, in start
    return self.__enter__()
  File "D:\App\Minconda\envs\py38\lib\site-packages\playwright\sync_api\_context_manager.py", line 70, in __enter__
    playwright = self._playwright
AttributeError: 'PlaywrightContextManager' object has no attribute '_playwright'
Traceback (most recent call last):
  File "C:\Users\hui\AppData\Roaming\JetBrains\PyCharm2020.3\plugins\evaluate-async-code\_pydevd_async_debug.py", line 458, in <module>
    run_path(sys.argv.pop(1), {}, "__main__")
  File "D:\App\Minconda\envs\py38\lib\runpy.py", line 265, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "D:\App\Minconda\envs\py38\lib\runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "D:\App\Minconda\envs\py38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\App\PyCharm 2020.3.5\plugins\python\helpers\pydev\pydevd.py", line 2167, in <module>
    main()
  File "D:\App\PyCharm 2020.3.5\plugins\python\helpers\pydev\pydevd.py", line 2158, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "D:\App\PyCharm 2020.3.5\plugins\python\helpers\pydev\pydevd.py", line 1470, in run
    return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
  File "D:\App\PyCharm 2020.3.5\plugins\python\helpers\pydev\pydevd.py", line 1477, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "D:\App\PyCharm 2020.3.5\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "D:/workspace/BaoBao/playwright_t.py", line 4, in <module>
    playwright = playwright_context_manager.start()
  File "D:\App\Minconda\envs\py38\lib\site-packages\playwright\sync_api\_context_manager.py", line 75, in start
    return self.__enter__()
  File "D:\App\Minconda\envs\py38\lib\site-packages\playwright\sync_api\_context_manager.py", line 70, in __enter__
    playwright = self._playwright
AttributeError: 'PlaywrightContextManager' object has no attribute '_playwright'

Full code screenshot

image

Complete error report screenshot

image

pycharm version

PyCharm 2020.3.5 (Professional Edition)
Build #PY-203.7717.81, built on March 25, 2021
Expiration date: June 26, 2021
Runtime version: 11.0.10+8-b1145.96 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 980M
Cores: 16

Plug-in version

image

uriyyo commented 3 years ago

Thanks for submitting this issue, I will try to fix it asap.

wordhui commented 3 years ago

Thanks for submitting this issue, I will try to fix it asap.

This plugin is very practical, thank you very much, I hope it will become more and more stable in the future

wordhui commented 3 years ago

Supplementary description, The version of playwright is 1.12.0

uriyyo commented 3 years ago

@wordhui Could you please provide more context?

I can not reproduce this issue with the latest version of plugin and python 3.8.

image

wordhui commented 3 years ago

@uriyyo My version of Python, from minconda

(py38) D:\>python
Python 3.8.8 (default, Feb 24 2021, 15:54:32) [MSC v.1928 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

The version of playwright is 1.12.0

(py38) D:\>pip list |findstr "playwright"
playwright                1.12.0

The versions of pycharm and plugins are explained above

If the bug cannot be reproduced, I will continue to use the plug-in. If I find more information about the bug, I will update the situation

uriyyo commented 3 years ago

@wordhui Maybe it some kind of win specific issue, I will try to investigate and find root cause of this problem.

wordhui commented 3 years ago

@uriyyo After my test, Python3.9 and Python3.8 created in minconda using the evaluate-async-code plug-in to debug the above code will have the above problem, but using the above plug-in in Python3.7 created by minconda will not have this problem, maybe Related to minconda or Python version In order to be able to reproduce this problem, I packaged my local minconda Python environment to Google Cloud Disk, you can download it, and assign the python interpreter in pycharm to my virtual environment, and then debug the above code to see if it can be reproduced This problem, if Ren can not reproduce this problem, I guess there is no way to reproduce it in a short time

Download link for my virtual environment: https://drive.google.com/file/d/12F1DCsooTOFIiD0HVKcaaQZG3DTC8DHi/view?usp=sharing

In pycharm, point the Python interpreter to the python3.9 virtual environment I uploaded

image

Debugging the code will reproduce this problem
image

uriyyo commented 3 years ago

Thanks, I will take a look

wordhui commented 3 years ago

Thanks, I will take a look

Thank you The above invalid picture, I updated it again, you can see the bug reproduction steps from the picture

uriyyo commented 3 years ago

Hi @wordhui,

New version 1.14 has been released. Do you still have an issue with plugin?

wordhui commented 3 years ago

Hi @wordhui,

New version 1.14 has been released. Do you still have an issue with plugin?

I upgraded to version 1.14, the above problem still exists If I have time, I will copy the Python environment of this computer to another computer for testing to see if it is a special environmental problem of this computer.

D:\App\Minconda\envs\py39\python.exe C:\Users\hui\AppData\Roaming\JetBrains\PyCharm2020.3\plugins\evaluate-async-code\_pydevd_async_debug.py "D:\App\PyCharm 2020.3.5\plugins\python\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 5819 --file D:/workspace/BaoBao/other/sticapply/pw_t.py
Connected to pydev debugger (build 203.7717.81)
Traceback (most recent call last):
  File "D:\App\PyCharm 2020.3.5\plugins\python\helpers\pydev\pydevd.py", line 1477, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "D:\App\PyCharm 2020.3.5\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "D:/workspace/BaoBao/other/sticapply/pw_t.py", line 5, in <module>
    playwright = manager.start()
  File "D:\App\Minconda\envs\py39\lib\site-packages\playwright\sync_api\_context_manager.py", line 75, in start
    return self.__enter__()
  File "D:\App\Minconda\envs\py39\lib\site-packages\playwright\sync_api\_context_manager.py", line 70, in __enter__
    playwright = self._playwright
AttributeError: 'PlaywrightContextManager' object has no attribute '_playwright'
Traceback (most recent call last):
  File "C:\Users\hui\AppData\Roaming\JetBrains\PyCharm2020.3\plugins\evaluate-async-code\_pydevd_async_debug.py", line 493, in <module>
    run_path(sys.argv.pop(1), {}, "__main__")
  File "D:\App\Minconda\envs\py39\lib\runpy.py", line 268, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "D:\App\Minconda\envs\py39\lib\runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "D:\App\Minconda\envs\py39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\App\PyCharm 2020.3.5\plugins\python\helpers\pydev\pydevd.py", line 2167, in <module>
    main()
  File "D:\App\PyCharm 2020.3.5\plugins\python\helpers\pydev\pydevd.py", line 2158, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "D:\App\PyCharm 2020.3.5\plugins\python\helpers\pydev\pydevd.py", line 1470, in run
    return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
  File "D:\App\PyCharm 2020.3.5\plugins\python\helpers\pydev\pydevd.py", line 1477, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "D:\App\PyCharm 2020.3.5\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "D:/workspace/BaoBao/other/sticapply/pw_t.py", line 5, in <module>
    playwright = manager.start()
  File "D:\App\Minconda\envs\py39\lib\site-packages\playwright\sync_api\_context_manager.py", line 75, in start
    return self.__enter__()
  File "D:\App\Minconda\envs\py39\lib\site-packages\playwright\sync_api\_context_manager.py", line 70, in __enter__
    playwright = self._playwright
AttributeError: 'PlaywrightContextManager' object has no attribute '_playwright'
uriyyo commented 2 years ago

Hi @wordhui,

Could you please try to upgrade to version 1.20 and check if this issue is still present?

uriyyo commented 2 years ago

I am closing this issue, please reopen it in case if the issue is still present.