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.

az postgres flexible-server error - "No module named 'psycopg2._psycopg'

See original GitHub issue

Describe the bug

This issue occurred when running az postgres flexible-server --help so I could see what parameters were needed.

Command Name az postgres flexible-server

Errors:

The command failed with an unexpected error. Here is the traceback:
No module named 'psycopg2._psycopg'
Traceback (most recent call last):
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 231, in invoke
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 583, in execute
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/parser.py", line 261, in parse_args
  File "argparse.py", line 1825, in parse_args
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/parser.py", line 284, in parse_known_args
  File "argparse.py", line 1858, in parse_known_args
  File "argparse.py", line 2049, in _parse_known_args
  File "argparse.py", line 2026, in consume_positionals
  File "argparse.py", line 1935, in take_action
  File "argparse.py", line 1213, in __call__
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/parser.py", line 284, in parse_known_args
  File "argparse.py", line 1858, in parse_known_args
  File "argparse.py", line 2049, in _parse_known_args
  File "argparse.py", line 2026, in consume_positionals
  File "argparse.py", line 1935, in take_action
  File "argparse.py", line 1213, in __call__
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/parser.py", line 284, in parse_known_args
  File "argparse.py", line 1858, in parse_known_args
  File "argparse.py", line 2067, in _parse_known_args
  File "argparse.py", line 2007, in consume_optional
  File "argparse.py", line 1935, in take_action
  File "argparse.py", line 1098, in __call__
  File "argparse.py", line 2555, in print_help
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/parser.py", line 195, in format_help
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/parser.py", line 248, in format_help
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/_help.py", line 165, in show_help
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/help.py", line 253, in __init__
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/_help.py", line 303, in load
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/_help_loaders.py", line 154, in versioned_load
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/help.py", line 198, in load
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/parser.py", line 241, in __getattribute__
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 133, in description_loader
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 59, in get_op_handler
  File "importlib\__init__.py", line 126, in import_module
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\charris\.azure\cliextensions\rdbms-connect\azext_rdbms_connect\custom.py", line 10, in <module>
    import psycopg2
  File "C:\Users\charris\.azure\cliextensions\rdbms-connect\psycopg2\__init__.py", line 51, in <module>
    from psycopg2._psycopg import (                     # noqa
ModuleNotFoundError: No module named 'psycopg2._psycopg'

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Put any pre-requisite steps here…
  • az postgres flexible-server --help

Expected Behavior

Output showing the parameters needed by the command

Environment Summary

Windows-10-10.0.22000-SP0
Python 3.10.3
Installer: MSI

azure-cli 2.35.0

Extensions:
azure-dev 0.0.1b456
containerapp 0.1.3
rdbms-connect 1.0.1

Dependencies:
msal 1.17.0
azure-mgmt-resource 20.0.0

Additional Context

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
seajhawkcommented, Apr 21, 2022

@navba-MSFT - Thanks for letting me know. I’m glad it’s getting fixed!

0reactions
navba-MSFTcommented, May 6, 2022

@seajhawk Please follow the above mentioned action plan once you get a chance. We will now proceed with closure of this github issue. If you need any further assistance on this issue in future, please feel free to reopen this thread. We would be happy to help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python 3.x - ImportError: No module named 'psycopg2._psycopg'
I am using psycopg in an AWS Glue Job, where is harder to follow the instructions listed in the other answers ...
Read more >
Connect with Python - Azure Database for PostgreSQL ...
This quickstart provides Python code samples that you can use to connect and query data from Azure Database for PostgreSQL - Single Server....
Read more >
ModuleNotFoundError: No module named 'psycopg2' in Python
To solve the error, install the module by running the pip install psycopg2-binary command. no module named psycopg2. Open your terminal in your...
Read more >
[Solved] ImportError: No Module Named 'psycopg2'
Many "No module named psycopg2" errors occur due to working on incorrect virtual environments and installing the 'psycopg2' on a totally...
Read more >
[Superset]: No module named psycopg2 - Cloudera Community
Solved: I am trying to add a postgres database to superset. This is my connection URI: - 211213.
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