Open monocongo opened 1 year ago
This shows that the package is included in the poetry packages:
% python -m poetry show pymssql
name : pymssql
version : 2.2.7
description : DB-API interface to Microsoft SQL Server for Python. (new Cython-based version)
I can reproduce this with
$ docker run -d \
-p "1433:1433" \
-e "SA_PASSWORD=Meltan0admin" \
-e "ACCEPT_EULA=Y" \
--name mssql \
--health-cmd "/opt/mssql-tools/bin/sqlcmd -U sa -P Meltan0admin -Q 'select 1' -b -o /dev/null" \
--health-interval 10s \
--health-timeout 5s \
--health-retries 5 \
mcr.microsoft.com/mssql/server:2019-latest
and
>>> import sqlalchemy as sa
>>> from sqlalchemy.engine import URL
>>> url = URL.create(
... "mssql+pymssql",
... username="sa",
... password="Meltan0admin",
... host="localhost",
... port=1433,
... database="wh",
... query={"charset": "utf8"},
... )
>>> engine = sa.create_engine(url)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 2, in create_engine
File "/path/to/.venv/lib/python3.11/site-packages/sqlalchemy/util/deprecations.py", line 281, in warned
return fn(*args, **kwargs) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^
File "/path/to/.venv/lib/python3.11/site-packages/sqlalchemy/engine/create.py", line 601, in create_engine
dbapi = dbapi_meth(**dbapi_args)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/.venv/lib/python3.11/site-packages/sqlalchemy/dialects/mssql/pymssql.py", line 65, in import_dbapi
module = __import__("pymssql")
^^^^^^^^^^^^^^^^^^^^^
File "/path/to/.venv/lib/python3.11/site-packages/pymssql/__init__.py", line 3, in <module>
from ._pymssql import *
File "src/pymssql/_pymssql.pyx", line 1, in init pymssql._pymssql
ImportError: dlopen(/path/to/.venv/lib/python3.11/site-packages/pymssql/_mssql.cpython-311-darwin.so, 0x0002): symbol not found in flat namespace '_bcp_batch'
I get this same error using Python 3.11.6 in MacOS. I don't use Python directly, I use it with Robot Framework and I get this error when I try to connect to SQL Server database using Robot Framework DatabaseLibrary method Connect To Database with pymssql as a first parameter. https://marketsquare.github.io/Robotframework-Database-Library/#Connect%20To%20Database
Test The Database Connection | FAIL |
ImportError: dlopen(/Users/vmkiili/.pyenv/versions/3.11.6/lib/python3.11/site-packages/pymssql/_mssql.cpython-311-darwin.so, 0x0002): symbol not found in flat namespace '_bcp_batch'
It works fine in Windows environment. I don't have any problems with pymssql in MacOS if I use Python 3.10.13.
MacOS Sonoma 14.2 Apple M2 Max Python 3.11.6 pymssql 2.2.11, 2.2.10, 2.2.9, 2.2.8, 2.2.7, 2.2.6, 2.1.5
all same behavior:
ImportError: dlopen(/venv/lib/python3.11/site-packages/pymssql/_mssql.cpython-311-darwin.so, 0x0002): symbol not found in flat namespace '_bcp_batch'
To add to the momentum, I've been having this issue ever since attempting to switch from Python 3.10 to 3.11. This is the only blocker preventing me from bumping Python above 3.10
System:
(edit: typo in pymssql version)
I think that the problem is similar to what is described here. Try to compile pymssql from source using hint from #769
I think that the problem is similar to what is described here. Try to compile pymssql from source using hint from #769
Thanks, this does seem to work for me. With the following setup
I added this to the poetry.toml
file in my project:
[installer]
no-binary = ["pymssql"]
After rebuilding my Poetry environment, I can connect to SQL Server and run queries without issue
Another way to fix it is using the following command:
pip install --pre --no-binary :all: pymssql==2.2.11 --no-cache --force
Not really fixed, but working with a older version of pymssql like mentioned above.
Describe the bug I have code that imports
pymssql
. When I run this code I get the following import error indicating that a BCP symbol is missing:The project's
pyproject.toml
file includes the latest version ofpymssql
in its list of dependencies:To Reproduce Since the code I'm seeing this happen in is proprietary I can't post that here. But the issue happens at the time of import, at least that's what it looks like to me. Starting with a fresh clone of the repository I am doing these steps to get the above error:
Expected behavior No import error
Current Behavior Please see the above description of the error.
Context (Environment)
==> freetds: stable 1.3.18 (bottled), HEAD Libraries to talk to Microsoft SQL Server and Sybase databases https://www.freetds.org/ Not installed From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/freetds.rb License: GPL-2.0-or-later ==> Dependencies Build: pkg-config ✔ Required: openssl@3 ✔, unixodbc ✔ ==> Options --HEAD Install HEAD version ==> Analytics install: 3,673 (30 days), 3,673 (90 days), 3,673 (365 days) install-on-request: 0 (30 days), 0 (90 days), 0 (365 days) build-error: 0 (30 days)
% python -c "import pymssql; print(pymssql.version_info())" Traceback (most recent call last): File "", line 1, in
File "/Users/jadams/miniconda3/envs/mpw680/lib/python3.11/site-packages/pymssql/init.py", line 3, in
from ._pymssql import *
File "src/pymssql/_pymssql.pyx", line 1, in init pymssql._pymssql
ImportError: dlopen(/Users/jadams/miniconda3/envs/mpw680/lib/python3.11/site-packages/pymssql/_mssql.cpython-311-darwin.so, 0x0002): symbol not found in flat namespace '_bcp_batch'