dbcli / pgcli

Postgres CLI with autocompletion and syntax highlighting
http://pgcli.com
BSD 3-Clause "New" or "Revised" License
12.04k stars 553 forks source link

pgcli 4.0 - ModuleNotFoundError: No module named 'six' #1436

Closed elgrove closed 10 months ago

elgrove commented 11 months ago

Description

After having upgraded to v4.0, pgcli command returns error ModuleNotFoundError: No module named 'six'

❯ pgcli
Traceback (most recent call last):
  File "/opt/homebrew/bin/pgcli", line 5, in <module>
    from pgcli.main import cli
  File "/opt/homebrew/Cellar/pgcli/4.0.0/libexec/lib/python3.12/site-packages/pgcli/main.py", line 1, in <module>
    from configobj import ConfigObj, ParseError
  File "/opt/homebrew/Cellar/pgcli/4.0.0/libexec/lib/python3.12/site-packages/configobj/__init__.py", line 22, in <module>
    import six
ModuleNotFoundError: No module named 'six'

Solutions tried without success:

Your environment

elgrove commented 11 months ago

Update

I ran brew install six and got an upgrade of six from 1.16.0_3 -> 1.16.0_4, this progressed me to a new error

❯ pgcli
/opt/homebrew/Cellar/pgcli/4.0.0/libexec/lib/python3.12/site-packages/pgspecial/main.py:237: SyntaxWarning: invalid escape sequence '\w'
  """
Traceback (most recent call last):
  File "/opt/homebrew/bin/pgcli", line 5, in <module>
    from pgcli.main import cli
  File "/opt/homebrew/Cellar/pgcli/4.0.0/libexec/lib/python3.12/site-packages/pgcli/main.py", line 21, in <module>
    from cli_helpers.tabular_output import TabularOutputFormatter
  File "/opt/homebrew/Cellar/pgcli/4.0.0/libexec/lib/python3.12/site-packages/cli_helpers/tabular_output/__init__.py", line 11, in <module>
    from .output_formatter import format_output, TabularOutputFormatter
  File "/opt/homebrew/Cellar/pgcli/4.0.0/libexec/lib/python3.12/site-packages/cli_helpers/tabular_output/output_formatter.py", line 15, in <module>
    from . import (
  File "/opt/homebrew/Cellar/pgcli/4.0.0/libexec/lib/python3.12/site-packages/cli_helpers/tabular_output/tabulate_adapter.py", line 17, in <module>
    import tabulate
ModuleNotFoundError: No module named 'tabulate'

python-tabulate is installed already, so I reinstalled it brew reinstall python-tabulate

Now pgcli works!

Solution

brew upgrade six

brew reinstall python-tabulate

truthdoug commented 11 months ago

I also had the problem with python-tabulate and brew reinstall python-tabulate fixed this. I've reinstalled six but I'm still getting the SyntaxWarning: invalid escape sequence '\w' warning.

The tabulate problem prevented pgcli from running. The other warning is just a warning... for now 😄


MacOS Sonoma 14.1 pgcli installed using homebrew, upgraded to 4.0 when the new homebrew formula was released

truthdoug commented 11 months ago

Looks like it's because of this (now fixed) issue in pgspecial: https://github.com/dbcli/pgspecial/pull/145

j-bennet commented 11 months ago

The fix was included into pgspecial 2.1.1, already released. See if this helps.

truthdoug commented 11 months ago

Hmmm, if I install from source locally, it pulls the 2.1.1 release. However, I tried brew reinstall pgcli and brew uninstall pgcli; brew install pgcli and it's still using the 2.1.0 release.

A bit more digging and I found the culprit: the homebrew formula has the 2.1.0 release pinned in pgcli's resources

(Now to recall the instructions for submitting a patch for a new homebrew release...)

dbaty commented 10 months ago

Thanks for digging in. If I understand correctly, the remaining issue is in the Homebrew formula (if it has not been fixed already). @elgrove and @truthdoug: could you please confirm? If so, we'll close this issue.

(I cannot reproduce any of the aforementioned errors on a standard pip install pgcli, so I strongly suspect that any remaining issue will be in the Homebrew formula and should be raised there, not here.)

truthdoug commented 10 months ago

Yes, confirmed. I updated pgcli to 4.0.1 and the problem is resolved. I'm ok with closing this issue (but cannot do so myself)