kayak / pypika

PyPika is a python SQL query builder that exposes the full richness of the SQL language using a syntax that reflects the resulting query. PyPika excels at all sorts of SQL queries but is especially useful for data analysis.
http://pypika.readthedocs.io/en/latest/
Apache License 2.0
2.43k stars 292 forks source link

[bug] ImportError: cannot import name 'ClickHouseQuery' from 'pypika.dialects' (\.venv\lib\site-packages\pypika\dialects\__init__.py) #781

Closed jiangying000 closed 5 months ago

jiangying000 commented 6 months ago

If i rename dialects dirname, problem solved

version: pypika 0.48.9

jiangying000 commented 6 months ago

image https://pypi.org/project/PyPika/

a stale version problem

jiangying000 commented 6 months ago

@antoninkriz could you help with this ?

antoninkriz commented 6 months ago

@antoninkriz could you help with this ?

Hi, I don't think I'm the right person to reach out to as I'm not the maintainer of this project, I made just a single contribution. Sorry.

As for the bug, I think you should provide minimal reproducible example for the developers, they'll need more information to work with.

jiangying000 commented 6 months ago

@antoninkriz could you help with this ?

Hi, I don't think I'm the right person to reach out to as I'm not the maintainer of this project, I made just a single contribution. Sorry.

As for the bug, I think you should provide minimal reproducible example for the developers, they'll need more information to work with.

oh thanks, I believe @twheys and @mikeengland are maintainers this bug is due to excessive dialect directory at the pypi package, just download that lastest (0.48.9) package at pypi and we can see the problem

wd60622 commented 6 months ago

hi @jiangying000 Can you create a reproducible example and /or explain your python setup and installation of pypika?

I am able to install the latest version and import the class in the way I'd expect:

FROM python:3.11.5
RUN pip install pypika
CMD ["python", "-c", "from pypika.dialects import ClickHouseQuery; print(ClickHouseQuery); print('ClickHouseQuery was sucessfully loaded!')"]
docker build -t pypika-test . && docker run pypika-test
# <class 'pypika.dialects.ClickHouseQuery'>
# ClickHouseQuery was sucessfully loaded!

Pypika doesn't have the path pypika/dialects/__init__.py the ClickHouseQuery is imported from pypika/dialects.py

wd60622 commented 5 months ago

Did this get resolved? If so, feel free to close

jiangying000 commented 5 months ago

Yes, sorry i forgot this

H3d9 commented 4 months ago

hi @jiangying000 Can you create a reproducible example and /or explain your python setup and installation of pypika?

I am able to install the latest version and import the class in the way I'd expect:

FROM python:3.11.5
RUN pip install pypika
CMD ["python", "-c", "from pypika.dialects import ClickHouseQuery; print(ClickHouseQuery); print('ClickHouseQuery was sucessfully loaded!')"]
docker build -t pypika-test . && docker run pypika-test
# <class 'pypika.dialects.ClickHouseQuery'>
# ClickHouseQuery was sucessfully loaded!

Pypika doesn't have the path pypika/dialects/__init__.py the ClickHouseQuery is imported from pypika/dialects.py

I meet the same problem. I use pip uninstall pypika and find out that there's still a folder "dialects" in site-packages/pypika, so I delete the whole folder and reinstalled it, now it works