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/
Related
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
I want to use pyfftw module and I install it using sudo apt-get install python-fftw. The FFTW module is already installed. However, when I try to import pyfftw this error happens:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/pyfftw/__init__.py", line 16, in <module>
from .pyfftw import (
ImportError: /usr/lib/python2.7/dist-packages/pyfftw/pyfftw.arm-linux-gnueabihf.so: undefined symbol: fftwl_plan_with_nthreads
Anyone knows how to troubleshoot this? For additional information, my system architecture is armv7l (I am running the program in odroid), my OS is Ubuntu and I use python 2.7.12.
Thank you.
When I am compiling my code, I am getting the following error:
Traceback (most recent call last):
File "test.py", line 2, in <module>
from nameparser.parser import HumanName
ImportError: No module named nameparser.parser
How do I rectify it?
Works fine for me. Maybe, you haven't installed the module? Try something like
pip install nameparser
in your command line. Or sudo pip install nameparser, if this doesn't work.
P.S. Btw, you are most probably not 'compiling' your code ;)
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.
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