dbt-msft / dbt-sqlserver

dbt adapter for SQL Server and Azure SQL
MIT License
216 stars 101 forks source link

ImportError: cannot import name '__diag__' from partially initialized module 'pip._vendor.pyparsing' #454

Open hongbo-miao opened 1 year ago

hongbo-miao commented 1 year ago

I am using Poetry 1.6.1.

I have a file pyproject.toml:

[tool.poetry]
name = "my_app"
version = "0.0.1"
description = ""
authors = ["Hongbo Miao"]

[tool.poetry.dependencies]
python = "3.11.x"

[tool.poetry.group.dev.dependencies]
dbt-sqlserver = "1.4.3"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

This

poetry lock --no-update
poetry install

will give me error

Installing dependencies from lock file

Package operations: 7 installs, 11 updates, 0 removals

  • Updating setuptools (68.0.0 -> 68.2.2): Pending...
  • Updating setuptools (68.0.0 -> 68.2.2): Installing...
  • Updating setuptools (68.0.0 -> 68.2.2): Failed

  CalledProcessError

  Command '['/my_app/.venv/bin/python', '-m', 'pip', 'uninstall', 'setuptools', '-y']' returned non-zero exit status 1.

  at /opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py:571 in run
       567│             # We don't call process.wait() as .__exit__ does that for us.
       568│             raise
       569│         retcode = process.poll()
       570│         if check and retcode:
    →  571│             raise CalledProcessError(retcode, process.args,
       572│                                      output=stdout, stderr=stderr)
       573│     return CompletedProcess(process.args, retcode, stdout, stderr)
       574│ 
       575│ 

The following error occurred when trying to handle this error:

  EnvCommandError

  Command ['/my_app/.venv/bin/python', '-m', 'pip', 'uninstall', 'setuptools', '-y'] errored with the following return code 1

  Output:
  Traceback (most recent call last):
    File "<frozen runpy>", line 198, in _run_module_as_main
    File "<frozen runpy>", line 88, in _run_code
    File "/my_app/.venv/lib/python3.11/site-packages/pip/__main__.py", line 22, in <module>
      from pip._internal.cli.main import main as _main
    File "/my_app/.venv/lib/python3.11/site-packages/pip/_internal/cli/main.py", line 10, in <module>
      from pip._internal.cli.autocompletion import autocomplete
    File "/my_app/.venv/lib/python3.11/site-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
      from pip._internal.cli.main_parser import create_main_parser
    File "/my_app/.venv/lib/python3.11/site-packages/pip/_internal/cli/main_parser.py", line 9, in <module>
      from pip._internal.build_env import get_runnable_pip
    File "/my_app/.venv/lib/python3.11/site-packages/pip/_internal/build_env.py", line 17, in <module>
      from pip._internal.metadata import get_default_environment, get_environment
    File "/my_app/.venv/lib/python3.11/site-packages/pip/_internal/metadata/__init__.py", line 9, in <module>
      from .base import BaseDistribution, BaseEnvironment, FilesystemWheel, MemoryWheel, Wheel
    File "/my_app/.venv/lib/python3.11/site-packages/pip/_internal/metadata/base.py", line 35, in <module>
      from pip._internal.utils.packaging import safe_extra
    File "/my_app/.venv/lib/python3.11/site-packages/pip/_internal/utils/packaging.py", line 7, in <module>
      from pip._vendor.packaging.requirements import Requirement
    File "/my_app/.venv/lib/python3.11/site-packages/pip/_vendor/packaging/requirements.py", line 12, in <module>
      from pip._vendor.pyparsing import Combine
    File "/my_app/.venv/lib/python3.11/site-packages/pip/_vendor/pyparsing/__init__.py", line 130, in <module>
      from .common import _builtin_exprs as common_builtin_exprs
    File "/my_app/.venv/lib/python3.11/site-packages/pip/_vendor/pyparsing/common.py", line 5, in <module>
      from .helpers import DelimitedList, any_close_tag, any_open_tag
    File "/my_app/.venv/lib/python3.11/site-packages/pip/_vendor/pyparsing/helpers.py", line 7, in <module>
      from . import __diag__
  ImportError: cannot import name '__diag__' from partially initialized module 'pip._vendor.pyparsing' (most likely due to a circular import) (/my_app/.venv/lib/python3.11/site-packages/pip/_vendor/pyparsing/__init__.py)

  at /opt/homebrew/Cellar/poetry/1.6.1/libexec/lib/python3.11/site-packages/poetry/utils/env/base_env.py:363 in _run
      359│                 output = subprocess.check_output(
      360│                     cmd, stderr=stderr, env=env, text=True, **kwargs
      361│                 )
      362│         except CalledProcessError as e:
    → 363│             raise EnvCommandError(e, input=input_)
      364│ 
      365│         return output
      366│ 
      367│     def execute(self, bin: str, *args: str, **kwargs: Any) -> int:

make: *** [poetry-install] Error 1

Any ideas? Thanks!

DmitriyReztsov commented 9 months ago

I caught such error after isort changed all imports in venv folders. I removed venv and made it again.