ImportError with psycopg2 - python

I've been trying to install psycopg2 on my OS X Yosemite machine for the past two days. I have python, postgreSQL installed. I've tried installing psycopg2 using:
sudo pip install psycopg2
It gets successfully installed, but when I import it in the python shell, I get this:
import psycopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/psycopg2/__init__.py",
line 50, in <module> from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/psycopg2/_psycopg.so, 2):
Symbol not found: _lo_lseek64
Referenced from: /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/psycopg2/_psycopg.so
Expected in: /usr/lib/libpq.5.dylib
in /Library/Frameworks/Python.frame
I've looked at all the Stack Overflow questions related to this. Nothing works!
I've also tried mac ports and I get a similar result.
update:
I did what this said. Now I'm getting this:
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: libssl.1.0.0.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/psycopg2/_psycopg.so
Reason: image not found

Related

Symbol not found: Referenced from: Expected in: flat namespace | macOS Big Sur

I've been trying import a Module using:
import pyexiv2
which yields an error
Aruns-MacBook-Air:scripts arun$ python3 99-new-camera.py crop_field
Traceback (most recent call last):
File "99-new-camera.py", line 7, in <module>
import pyexiv2 # dnf install python3-exiv2 (py3exiv2)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyexiv2/__init__.py", line 60, in <module>
import libexiv2python
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/libexiv2python.cpython-37m-darwin.so, 2): Symbol not found: _PyCMethod_New
Referenced from: /usr/local/opt/boost-python3/lib/libboost_python39.dylib
Expected in: flat namespace
in /usr/local/opt/boost-python3/lib/libboost_python39.dylib
I already have all the dependencies installed, I don't see why this error is being raised. I'm running Python 3.7 on macOS Big Sur. Are there any workarounds for this issue?
I believe I've found a solution to the problem from this post which suggests a fix by adding a linker flag -lboost-python3. How do I add a linker flag and fix this issue?

error while importing MySQL from flask_mysqldb in python 2.7.10

Recently I've been working on flask. I'm getting an error while importing MySQL.
from flask_mysqldb import MySQL
I spend most of day yesterday, trying different solution from stack overflow to get it worked but nothing is working, So I'm posting a new question.
from flask_mysqldb import MySQL
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/abhishek/Library/Python/2.7/lib/python/site-packages/flask_mysqldb/__init__.py", line 1, in <module>
import MySQLdb
File "/Users/abhishek/Library/Python/2.7/lib/python/site-packages/MySQLdb/__init__.py", line 18, in <module>
import _mysql
ImportError: dlopen(/Users/abhishek/Library/Python/2.7/lib/python/site-packages/_mysql.so, 2): Library not loaded: #rpath/libmysqlclient.21.dylib
Referenced from: /Users/abhishek/Library/Python/2.7/lib/python/site-packages/_mysql.so
Reason: image not found
I'm Working on MacOS Mojave.
Installed flask
pip install flask
Installed flask-mysqldb
pip install flask-mysqldb
Installed MySQL from macOS 10.13 (x86, 64-bit), DMG Archiv

Not able to import mysqldb in python on mac

I am new to mac and to python. I have installed mysqldb for python mac. But when i try to import it, this is the error i am getting :
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.6/site-packages/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: dlopen(/Library/Python/2.6/site-packages/_mysql.so, 2): Symbol not found: _strnlen
Referenced from: /usr/lib/libmysqlclient.18.dylib
Expected in: /usr/lib/libSystem.B.dylib
in /usr/lib/libmysqlclient.18.dylib
Why am i getting this error? How do i resolve it? I have tried a crazy number of answers posted here on SO but nothing seems to work. What should i do to resolve this error?
Thanks.
Did you use sudo when you installed?
sudo pip install mysql-python
Then add this line to your ~/.bash_profile
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/

Issues related to psycopg2

I am running EPD python 2.7.3. I have installed psycopg2 by easy_install . But When i try to import the psycopg2, It shows the following error:
>>>import psycopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Symbol not found: _PQbackendPID
Referenced from: /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/psycopg2/_psycopg.so
Expected in: dynamic lookup
I am runnin mac osx Mountain lion. Any suggestion?
it should work, i installed with $ sudo apt-get command on Ubuntu. everything work fine. may try to uninstall the postgresql and reinstall it.

Error installing psycopg2 on Mac OS 10.6

Hi i am trying to install psycopg2 on Mac 10.6. After i install i get this error when i try to import
import psycopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.6/site-packages/psycopg2/__init__.py", line 69, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: dlopen(/Library/Python/2.6/site-packages/psycopg2/_psycopg.so, 2): Symbol not found: _PQbackendPID
Referenced from: /Library/Python/2.6/site-packages/psycopg2/_psycopg.so
Expected in: flat namespace
in /Library/Python/2.6/site-packages/psycopg2/_psycopg.so
I got the source from http://initd.org/psycopg/download/ and tried to build from source using setup/easy_install with the value for pg_config set to /Library/PostgreSQL/8.4/bin/pg_config in setup.cfg
I tried all these alternatives and nothing seems to work
http://blog.timc3.com/2010/08/20/psycopg2-os-x-_pqbackendpid/
http://initd.org/psycopg/articles/2010/11/11/links-about-building-psycopg-mac-os-x/
Any ideas whats happening here??
According to this link, psycopg2 seems must work in 32bit mode on MacOSX

Categories