在平面命名空间“_bcp_batch”中找不到符号

问题描述 投票:0回答:1

我正在使用 pyenv 来管理我的 python 版本。 当我使用 python 3.12.4 或 python3.9^ 时,出现此错误:

 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'

我的脚本:

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()

我有 Mac m3 芯片,我该如何修复它?

谢谢

python python-3.x macos pip pymssql
1个回答
0
投票

这是一个已知错误。

您可以与

pymssql==2.2.11

合作

试试这个:

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 链接:

https://github.com/pymssql/pymssql/issues/891#issuecomment-2145767580

https://github.com/pymssql/pymssql/issues/769

© www.soinside.com 2019 - 2024. All rights reserved.