1

I am trying to add a database to a new python app. Postgres is my db of choice, it works on my machine with many rails apps, is up and running, and I have created a db for my project.

Troubleshooting so far:

pip install psycopg2

render looks appropriate:

Requirement already satisfied (use --upgrade to upgrade): psycopg2 in /usr/local/lib/python2.7/site-packages
Cleaning up...

ok, testing it

python

>> import psycopg2

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/__init__.py", line 50, in <module>
    from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: dlopen(/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: @loader_path/../lib/libssl.1.0.0.dylib
  Referenced from: /usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so
  Reason: image not found

Looks like a module problem.

In my bash_profile I am exporting the correct version of psql:

export PATH=/usr/pgsql-9.3/bin:"$PATH"

My database settings shouldn't matter as it fails the test before I start running a server but:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'firstBlog',
        'USER': 'ML',
        'PASSWORD': '',
        'HOST': '127.0.0.1',
        'PORT': '5432',
    }
}

Of course, attempting to run the server will also crash it.

Brew Doctor is not turning up any errors. Any ideas where I can continue to troubleshoot?

5
  • Could be related: stackoverflow.com/questions/16407995/psycopg2-image-not-found Commented Feb 21, 2014 at 3:56
  • What does "which pip" and "which python" tell you? I think you have a confusion between your system python stuff and brew packages. And what is your PATH and PYTHONPATH? Commented Feb 21, 2014 at 4:29
  • You should probably use virtualenv if you don't already. Simplifies a lot of this stuff and prevents you from polluting the system python installation. Commented Feb 21, 2014 at 4:30
  • $ which pip '/usr/local/bin/pip' $ which python '/usr/local/bin/python' If I go back to follow the instructions [link] ( virtualenv.org/en/latest/virtualenv.html ) it errors, so it looks like I'll need to troubleshoot virtualenv before postgres. Thanks for the help. Commented Feb 22, 2014 at 16:15
  • @karthikr , the solution by stephenalexbrowne on the page you linked worked for me. Thank you. Commented Feb 22, 2014 at 17:09

1 Answer 1

1

In this case, it seems that my environmental variables weren't exporting psql properly for Django. I found a solution on the page linked by @karthikr that solved it.

https://stackoverflow.com/a/16740552/2967262

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.