设置所有内容后,Python无法在Heroku上找到ODBC驱动程序 [英] Python cant find ODBC Driver on Heroku after setting everything

查看:267
本文介绍了设置所有内容后,Python无法在Heroku上找到ODBC驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经遍历了Internet上所有可能的解决方案,但无法使pyobdc在heroku上获得驱动程序.

I have gone through every possible solution on the internet, but I'm unable to make pyobdc get the drivers on heroku.

我用来创建应用程序的步骤如下:

The steps I have used to create the app are as follows:

heroku create
heroku config:set FLASK_CONFIG=heroku 

heroku buildpacks:add heroku/python
heroku buildpacks:add --index 1 heroku-community/apt

git push heroku master 

即使使用odbc buildpack,我也尝试过,但还是没有运气:

I tried even with odbc buildpack but still no luck:

heroku buildpacks:add https://github.com/iFix/heroku-buildpack-odbc.git

浏览完Microsoft网站后,我修剪了Aptfile以便插入heroku以安装以下软件包:

After going through microsoft website, I trimmed down my Aptfile to instuct heroku to install the following packages:

# install msodbcsql17
https://packages.microsoft.com/ubuntu/16.04/prod/pool/main/m/msodbcsql17/msodbcsql17_17.4.2.1-1_amd64.deb
# install mssql-tools
https://packages.microsoft.com/ubuntu/16.04/prod/pool/main/m/mssql-tools/mssql-tools_17.4.1.1-1_amd64.deb
# install unixodbc-dev
unixodbc-dev

这使pyodbc安装顺利进行.但是,当我运行pyodbc.drivers()时,它什么也不返回.在Ubuntu 16.04上,相同的命令将返回用于SQL Server的ODBC驱动程序17"

This makes pyodbc installation go without error. But when I run pyodbc.drivers(), it returns nothing. The same command on Ubuntu 16.04 returns "ODBC Driver 17 for SQL Server"

该项目的源代码位于: https://github.com/IamVNIE/odbcTestHeroku

The source code for the project is at : https://github.com/IamVNIE/odbcTestHeroku

托管应用位于: https://pyodbctest.herokuapp.com/

有人可以提供一些指示使这项工作完成吗?

Can someone please provide some pointers to make this work.

推荐答案

我已通过在运行Ubuntu 18.04的计算机上预编译用于SQL Server的ODBC Driver 17并将此libmsodbcsql-17.5.so.2.1msodbcsqlr17.rll文件复制到适当的目录中,解决了此问题.通过一个Heroku buildpack.这是用于SQL Server的ODBC驱动程序17.5,我可能不会编译该驱动程序的其他版本,但是我认为概念仍然相同.

I have solved this issue by precompiling ODBC Driver 17 for SQL Server on a machine running Ubuntu 18.04 and copying the libmsodbcsql-17.5.so.2.1 and msodbcsqlr17.rll files into appropriate directories via a Heroku buildpack. This is ODBC Driver 17.5 for SQL Server and I likely won't be compiling other versions of this driver, but I imagine the concept remains the same.

Heroku buildpack及其要求可在此处找到https://github.com/matt-bertoncello/python-pyodbc-buildpack.git

The Heroku buildpack and its requirements can be found here https://github.com/matt-bertoncello/python-pyodbc-buildpack.git

这篇关于设置所有内容后,Python无法在Heroku上找到ODBC驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆