Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: command not found: initdb #38

Open
Priyadhana opened this issue Aug 24, 2021 · 3 comments
Open

RuntimeError: command not found: initdb #38

Priyadhana opened this issue Aug 24, 2021 · 3 comments

Comments

@Priyadhana
Copy link

Hi , I wanted to write test-cases involving postgres for flask applicattion. When I was trying the testing.postgresql package, it's throwing this command not found: initdb error.
This is the code I'm trying,

import unittest
import testing.postgresql

Generate Postgresql class which shares the generated database

Postgresql = testing.postgresql.PostgresqlFactory(cache_initialized_db=True)

def tearDownModule(self):
# clear cached database at end of tests
Postgresql.clear_cache()

class MyTestCase(unittest.TestCase):
def setUp(self):
# Use the generated Postgresql class instead of testing.postgresql.Postgresql
self.postgresql = Postgresql()

def tearDown(self):
    self.postgresql.stop()

When I ran pytest, I'm getting this error,

src\tests\app\test_db.py:25: in
Postgresql = testing.postgresql.PostgresqlFactory(cache_initialized_db=True)
..\user\appdata\local\programs\python\python39\lib\site-packages\testing\common\database.py:52: in init
self.cache = self.target_class(**settings_noautostart)
..\user\appdata\local\programs\python\python39\lib\site-packages\testing\common\database.py:92: in init
self.initialize()
..\user\appdata\local\programs\python\python39\lib\site-packages\testing\postgresql.py:50: in initialize
self.initdb = find_program('initdb', ['bin'])
..\user\appdata\local\programs\python\python39\lib\site-packages\testing\postgresql.py:144: in find_program
raise RuntimeError("command not found: %s" % name)
E RuntimeError: command not found: initdb

I have set the path for "C:\Program Files\PostgreSQL\13\bin" in my environmental.

Am I missing something? Can someone help me out here.

@saveshodhan
Copy link

See if #35 helps..

@asmaier
Copy link

asmaier commented Feb 1, 2022

You need to install the postgres DB. On Mac OS simply do

brew install postgresql

Maybe the documentation should mention this as a requirement for the installation.

@anentropic
Copy link

after brew install postgresql I get a new error:

RuntimeError: command not found: postgres

brew info postgresql doesn't suggest anything wrong, but the fix for me was:

$ brew link postgresql
Linking /opt/homebrew/Cellar/postgresql@14/14.5_3.reinstall...
Error: Could not symlink bin/clusterdb
Target /opt/homebrew/bin/clusterdb
is a symlink belonging to libpq. You can unlink it:
  brew unlink libpq

To force the link and overwrite all conflicting files:
  brew link --overwrite postgresql@14

To list all files that would be deleted:
  brew link --overwrite --dry-run postgresql@14

$ brew link --overwrite postgresql@14
Linking /opt/homebrew/Cellar/postgresql@14/14.5_3.reinstall... 334 symlinks created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants