1

I want to use python-sql as per this link. python-sql project home. I install sql using "pip install sql", and it goes as planned. However, when I place the import at the top of my module;

from sql import *
from sql.aggregate import *
from sql.conditional import *

PyCharm indicates that sql.aggregate could not be resolved. If I try to execute the code, I get an error

ImportError: No module named 'sql.aggregate'; 'sql' is not a package

I've done a lot of searching on it and can't find what I am doing wrong. I'm a Python newbe, so I hope it is something simple - but I couldn't find anything in the docs about installation.

(Edit : system setup) - MS Windows 7 - Python 34 - Virtual Machine

snakecharmerb
  • 47,570
  • 11
  • 100
  • 153
SteveJ
  • 3,034
  • 2
  • 27
  • 47
  • You appear to have a `sql.py` file somewhere; e.g. a *module*, not a package. What does `import sql; print(sql.__file__)` say is being imported? – Martijn Pieters Jan 08 '15 at 16:44
  • @AnirudhaAgashe Yes, I am using a virtual machine. I guess I should have mentioned that in my setup. I'll add that now. – SteveJ Jan 08 '15 at 17:01
  • @MartijnPieters I get "C:\Python34\lib\site-packages\sql.py". Originally, PyCharm installed it for me. I tried pip uninstall, and a reinstall but it doesn't seem to help. – SteveJ Jan 08 '15 at 17:01
  • @SteveJ: ah, yes, because [`sql` on PyPI](https://pypi.python.org/pypi/sql) is a **different project**. – Martijn Pieters Jan 08 '15 at 17:02
  • @MartijnPieters : Sorry, I swim on the shallow end of the python pool. What does that mean for me? – SteveJ Jan 08 '15 at 17:05
  • @SteveJ: you installed the wrong project. The documentation you are referring to is for the `python-sql` project, but you installed the `sql` project instead. The prefix is part of the name here. – Martijn Pieters Jan 08 '15 at 17:09

1 Answers1

1

You need to install python-sql, not sql:

pip install python-sql

sql is a different project altogether.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • Thank you, that did the trick. In an effort to learn how to fish, how would I have known that on my own (so that I don't have to ask the same question in the future.) – SteveJ Jan 08 '15 at 17:12
  • @SteveJ: the project didn't document this, so I looked at the [`name` key in their `setup.py` file](https://code.google.com/p/python-sql/source/browse/setup.py#45); that is used to register with PyPI. – Martijn Pieters Jan 08 '15 at 17:13
  • @SteveJ: the fact that your `sql.py` file was found in `site-packages` indicated it was *probably* installed via `pip`, and indeed there was a PyPI page for a project named `sql` (found by typing in `pypi.python.org/pypi/` into my browser then adding `sql`). – Martijn Pieters Jan 08 '15 at 17:15