Search code examples
pythonpostgresqlpygresql

ModuleNotFoundError: No module named 'pg'


After trying to use pg library in Python as just as

import pg

I get this error message:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
    module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'pg'

how to import correctly the library?


Solution

  • The pg library has not the same name as the importing name so not very intuitive. According to the official documentation http://www.pygresql.org/contents/install.html in order to install it all you have to do is running

    pip install PyGreSQL