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

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?

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: Undefined Symbol when importing python module 'pyfftw'

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.

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/

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