Error installing psycopg2 on Mac OS 10.6 - python

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

Related

Python import MySQLdb on MacOS M1 doesn't work

I have Python 3.8.8, mysql and mysql-client installed. I also have installed both mysql-connector-python==8.0.26 & mysqlclient==2.1.0 library using pip.
But the line
python -c "import MySQLdb"
returns this error :
> Traceback (most recent call last):
File "/Users/louisgabilly/anaconda3/envs/venv/lib/python3.8/site-packages/MySQLdb/__init__.py", line 18, in <module>
from . import _mysql
ImportError: dlopen(/Users/louisgabilly/anaconda3/envs/venv/lib/python3.8/site-packages/MySQLdb/_mysql.cpython-38-darwin.so, 2): Symbol not found: _mysql_affected_rows
Referenced from: /Users/louisgabilly/anaconda3/envs/venv/lib/python3.8/site-packages/MySQLdb/_mysql.cpython-38-darwin.so
Expected in: flat namespace
in /Users/louisgabilly/anaconda3/envs/venv/lib/python3.8/site-packages/MySQLdb/_mysql.cpython-38-darwin.so
>
>During handling of the above exception, another exception occurred:
>
>Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/louisgabilly/anaconda3/envs/venv/lib/python3.8/site-packages/MySQLdb/__init__.py", line 24, in <module>
version_info, _mysql.version_info, _mysql.__file__
NameError: name '_mysql' is not defined
I believe this error is due to MacOS M1.
A good discussion is in https://github.com/PyMySQL/mysqlclient/issues/496 and this problem arises that the architecture (ARM64 or Intel) of the Python is not consistent with the architecture of mysqlclient. So, check which python you are using (since you might use some python you are not intended) and the consistence between them
Even though, you have installed mysqlclient, you need to install the Oracle native client library for it to work. You can install the client using brew.
brew install mysql-client
as this answer said
MySQLdb doesn’t support Python 3 you should be importing
import mysql.connector

ImportError with psycopg2

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

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.

Why isn't MySQLdb installation working on my 64bit Mac

>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.6-intel/egg/MySQLdb/__init__.py", line 19, in <module>
File "build/bdist.macosx-10.6-intel/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.6-intel/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/samwu/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so, 2): no suitable image found. Did find:
/Users/samwu/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so: mach-o, but wrong architecture
I think the problem must be the 64bit version of python and mysql and the img _mysql.so must be 32bit
can anybd give me some suggestions
thx advc!
---------append1------
I install MySQLdb just by modify the mysql_config.path = options['mysql_config'] in setup_posix.py and then rebuild like this python setup.py build and install,the mysql_config is point to your mysql
---------append2------
I can import MySQLdb,but it doesn't work in pydev
I checked the location of MySQLdb module in python shell like this :
import MySQLdb
print MySQLdb.__file__
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg/MySQLdb/_init_.pyc
then I add the egg to my pydev lib.it works
[CLOSED]
Do you have multiple versions of python installed? It may have installed to your non-default version and therefore won't work with it.

Categories