I’m using pyenv to manage my python versions.
When i use python 3.12.4 or python3.9^, i get this error:
File "src/pymssql/_pymssql.pyx", line 1, in init pymssql._pymssql
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pymssql/_mssql.cpython-312-darwin.so, 0x0002): symbol not found in flat namespace '_bcp_batch'
my script:
from sqlalchemy import create_engine, text
import bi_pass
v_server = bi_pass.v_server
v_user = bi_pass.v_user
v_password = bi_pass.v_password
v_database = bi_pass.v_database
source_engine = create_engine(f"mssql+pymssql://{v_user}:{v_password}@{v_server}:1433/{v_database}")
source_conn = source_engine.connect()
query = text( """ SELECT * from test""")
result = source_conn.execute(query)
rows = result.fetchall()
source_conn.close()
source_engine.dispose()
I have a Mac m3 chip, how can I fix it?
Thanks
This is a known error.
You can work with pymssql==2.2.11
Try this:
pip uninstall pymssql
brew install freetds
export CFLAGS="-I$(brew --prefix openssl)/include"
export LDFLAGS="-L$(brew --prefix openssl)/lib -L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I$(brew --prefix openssl)/include"
pip install --pre --no-binary :all: pymssql==2.2.11 --no-cache
git links:
https://github.com/pymssql/pymssql/issues/891#issuecomment-2145767580
https://github.com/pymssql/pymssql/issues/769