dbcli / mycli

A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting.
http://mycli.net
Other
11.32k stars 656 forks source link

Problems with running mycli in the development environment #1091

Closed ThinkingAgain closed 1 year ago

ThinkingAgain commented 1 year ago

When I build the mycli development environment and run it for the first time, the following error occurs:

Traceback (most recent call last):
  File "mycli/main.py", line 42, in <module>
    from .packages.special.main import NO_QUERY
ImportError: attempted relative import with no known parent package

When I removed the dot before packages of line 42:

from packages.special.mian import NO_QUERY

the error disappeared, what is the problem?

pasenor commented 1 year ago

Are you running the file main.py directly? The intended usage is to first install the package (pip install -e /path/to/mycli for dev environments) and then use the installed script ENV_ROOT/bin/mycli

ThinkingAgain commented 1 year ago

Yes, I running the filemain.py directly! Because I want to study the code. I followed the steps of the Development Guide clone the code. I'm a beginner and I want to know what is the correct way to debug the code and see the intermediate results of the run?

pasenor commented 1 year ago

Depends on your preferred setup for debugging, but you should (almost) always launch the generated mycli script.

If you use ipdb, then just install mycli with pip install -e /path/to/mycli (it links the source files instead of copying them, so that the changes are immediately reflected), and insert import ipdb; ipdb.set_trace() directly in the code.

If you use an IDE debugger, point it to bin/mycli as the executable.

ThinkingAgain commented 1 year ago

@pasenor Thank you for your patience in answering my question. I use Pycharm to debug the program, and now after setting the debug script to /scripts/mycli-script.py, I can do breakpoint debugging. Is this the right way to do it?

pasenor commented 1 year ago

yes, sounds right, have fun)