Pyodbc 驱动程序为空 [英] Pyodbc Drivers is Empty
问题描述
好的,我已经在 mac 上安装了 python3.8,分别安装了一些 odbcdrivers.我创建了一个新的虚拟环境,并在该环境中运行:
<预><代码>>>>导入pyodbc>>>pyodbc.drivers()[]>>>无论我在哪里运行命令,我都会得到这个.
您必须安装以下软件包才能列出来自 pyodbc 的驱动程序()
curl https://packages.microsoft.com/keys/microsoft.asc |apt-key 添加 -curl https://packages.microsoft.com/config/debian/9/prod.list >/etc/apt/sources.list.d/mssql-release.listapt-get 更新ACCEPT_EULA=Y apt-get -y install msodbcsql17apt-get -y 安装 unixodbc-dev
如果您在容器中运行 MSSQL,请在 dockerfile 中运行这些命令(如果您使用的是 Docker,请根据变体安装必要的软件包,如 curl 等.在运行上述命令之前)
其他任何内容只需按照此处的文档操作:https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15
Ok I've installed python3.8 on a mac, a number of odbcdrivers separately. I've created a new virtual environment and from within that environment run this:
>>> import pyodbc
>>> pyodbc.drivers()
[]
>>>
I get this no matter where I run the command.
You have to install the following Packages to list the drivers() from pyodbc
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list
apt-get update
ACCEPT_EULA=Y apt-get -y install msodbcsql17
apt-get -y install unixodbc-dev
If you are running the MSSQL in the container run those command in the dockerfile ( If you are using Docker, based on the variant install necessary packages like curl, etc. Before running the above command )
Anything else Just Follow the Docs Here: https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15
这篇关于Pyodbc 驱动程序为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!