question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ModuleNotFoundError: No module named 'psycopg2'

See original GitHub issue

Describe the bug sorry before this my first time use data-diff and when i want running this i got error like this even though i try to install

  • pip install psycopg2
  • ‘pip install data-diff[postgresql]’ the result is still same
[16:20:46] INFO - [PostgreSQL] Starting a threadpool, size=1.
[16:20:46] INFO - [PostgreSQL] Starting a threadpool, size=1.
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/data_diff/databases/base.py", line 39, in _inner
    return f()
  File "/usr/local/lib/python3.9/dist-packages/data_diff/databases/postgresql.py", line 10, in import_postgresql
    import psycopg2
ModuleNotFoundError: No module named 'psycopg2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/data-diff", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/data_diff/__main__.py", line 93, in main
    return _main(**kw)
  File "/usr/local/lib/python3.9/dist-packages/data_diff/__main__.py", line 216, in _main
    for op, columns in diff_iter:
  File "/usr/local/lib/python3.9/dist-packages/data_diff/diff_tables.py", line 325, in diff_tables
    table1, table2 = self._threaded_call("with_schema", [table1, table2])
  File "/usr/local/lib/python3.9/dist-packages/data_diff/diff_tables.py", line 504, in _threaded_call
    return list(self._thread_map(methodcaller(func), iterable))
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 600, in result_iterator
    yield fs.pop().result()
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 433, in result
    return self.__get_result()
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 389, in __get_result
    raise self._exception
  File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.9/dist-packages/data_diff/diff_tables.py", line 124, in with_schema
    schema = self.database.query_table_schema(self.table_path, self._relevant_columns)
  File "/usr/local/lib/python3.9/dist-packages/data_diff/databases/base.py", line 183, in query_table_schema
    rows = self.query(self.select_table_schema(path), list)
  File "/usr/local/lib/python3.9/dist-packages/data_diff/databases/base.py", line 100, in query
    res = self._query(sql_code)
  File "/usr/local/lib/python3.9/dist-packages/data_diff/databases/base.py", line 280, in _query
    return r.result()
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 440, in result
    return self.__get_result()
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 389, in __get_result
    raise self._exception
  File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.9/dist-packages/data_diff/databases/base.py", line 285, in _query_in_worker
    raise self._init_error
  File "/usr/local/lib/python3.9/dist-packages/data_diff/databases/base.py", line 274, in set_conn
    self.thread_local.conn = self.create_connection()
  File "/usr/local/lib/python3.9/dist-packages/data_diff/databases/postgresql.py", line 55, in create_connection
    pg = import_postgresql()
  File "/usr/local/lib/python3.9/dist-packages/data_diff/databases/base.py", line 44, in _inner
    raise ModuleNotFoundError(f"{e}\n\n{s}\n")
ModuleNotFoundError: No module named 'psycopg2'

You can install it using 'pip install data-diff[postgresql]'.

can you explain what should i do?? thats my toml

[database.pg96]
driver = "postgresql"
user = "xxx"
password = "xxx"
database = "xxx"
host = "xxx"
port = 5432

[database.replicapg96]
driver = "postgresql"
user = "xxx"
password = "xxx"
database = "xxx"
host = "xxx"
port = 5432


[run.default]
update_column = "updated_at"
verbose = true

[run.test_diff]
1.database = "xxx"
1.table = "xxx"
2.database = "xxx"
2.table = "xxx"

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13

github_iconTop GitHub Comments

1reaction
mathewtapilatucommented, Aug 16, 2022

its works thanks @cfernhout

0reactions
erezshcommented, Aug 24, 2022

Sorry I replied but looks like it didn’t post. Yes, if that’s the entire output, it means there is no difference.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ImportError: No module named psycopg2 - Stack Overflow
Please try to run the command import psycopg2 on the python console. If you get the error then check ...
Read more >
[Fixed] ModuleNotFoundError: No module named 'psycopg2'
How to Fix “ModuleNotFoundError: No module named 'psycopg2′” in PyCharm · Open File > Settings > Project from the PyCharm menu. · Select...
Read more >
ModuleNotFoundError: No module named 'psycopg2' in Python
The Python "ModuleNotFoundError: No module named 'psycopg2'" occurs when we forget to install the psycopg2-binary module before importing it or install it ...
Read more >
No module named 'psycopg2' + error during installation
importer.py", line 1, in <module> import psycopg2 ModuleNotFoundError: No module named 'psycopg2'. here is the python script:
Read more >
No module named psycopg2 - Odoo
ClueLogics Technologies Pvt. Ltd. ... It seems psycopg2 is not installed in your system. First install psycopg2 and then run OpenERP server. ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found