2017-07-07 61 views
4

我正嘗試在IBM Bluemix上託管我的應用程序。在我的應用程序中,我使用了燒瓶,並試圖連接到Azure SQL Server數據庫。爲此,我使用Pyodbc。在IBM Bluemix服務器上安裝pyodbc錯誤

所以在requirement.txt文件我已經給 pip install pyodbcpip install flask。 這些東西正在我的本地機器上安裝,應用程序運行良好。我從數據庫中獲得結果。

但是,當我試圖在IBM Bluemix上部署我的應用程序時, 在推送服務器上的文件時給了我一個錯誤。 我附上了下面的錯誤截圖。

requirement.txt的內容是這裏

unixodbc-dev 
pyodbc==3.1.1 
Flask==0.12.2 

Error Message

+0

環境是由雲代工buildpack定義的linux:http://docs.cloudfoundry.org/buildpacks/python/。您無權在環境中安裝軟件包,例如unixODBC。我期待看看是否有另一個包含unixODBC的buildpack。 –

+0

@ChrisSnow這些是我的requirements.txt的內容 'unixodbc-dev pyodbc == 3.1.1 Flask == 0.12.2' – PriyalChaudhari

+0

我在這裏創建了一個更具體的問題:https://stackoverflow.com/questions/44982510/fatal-error-sql -h -with-unixodbc-and-pyodbc-as-a-vendor-app-dependency –

回答

1

一種解決方案是使用miniconda安裝,而不是PIP您的依賴。將miniconda與buildpack一起使用記錄在here

有關使用miniconda安裝pyodbc的更多信息,請參閱here

+0

謝謝。我曾嘗試過這種解決方案。我的應用程序現在正在部署在服務器上,而且我沒有遇到任何錯誤。當在bluemix服務器上運行該應用程序時,出現此錯誤:pyodbc.Error:('01000',「[01000] [unixODBC] [驅動程序管理器]無法打開lib'SQL Server':文件未找到(0)( SQLDriverConnect)「)'我發佈我的代碼在aap.py文件中的下一個評論 – PriyalChaudhari

+0

這是我的代碼,我得到這個錯誤。這段代碼正在我的本地機器上運行。但在bluemix上出現以上錯誤。 '@ app.route('/ SQL// ')\t DEF api_sql(緯度,經度): \t cnxn = pyodbc.connect(' DRIVER = {SQL服務器}; SERVER = prashantvikramsingh.database.windows.net ;「DATABASE = Zillow; UID = prashant; PWD = Pvs758993 @') \t cursor = cnxn.cursor() \t cursor.execute(」SELECT top 10 * FROM [dbo]。[distance](「+ lat +」, + long +「)按距離排序」) \t rows = cursor.fetchall()' – PriyalChaudhari

+0

看看這個問題和答案:https://stackoverflow.com/questions/38534154/linux-python3-cant-open-lib - SQL服務器。如果這不能解決你的問題,我建議你接受你的原始問題的答案,然後創建一個新的問題。 –

-1

錯誤消息error: command 'gcc' failed with exit status 1使它看起來像你也許需要在該機器上安裝了gcc C/C++編譯器。

The pyodbc docs say

Windows

On Windows, you will need the appropriate Microsoft Visual C++ compiler. To build Python 2.4 or 2.5 versions, you will need the Visual Studio 2003 .NET compiler. Unfortunately there is no free version of this.

For Python 2.6 and above, you can use the free Visual C++ 2008 Express compiler. (Do not use the 2010 version! You need to use the version that your Python distribution was built with.)

You can create a Windows installer using: python setup.py bdist_wininst

Other

To build on other operating systems, use the gcc compiler.

On Linux, pyodbc is typically built using the unixODBC headers, so you will need unixODBC and its headers installed. On a RedHat/CentOS/Fedora box, this means you would need to install unixODBC-devel:

yum install unixODBC-devel


相關:Unable to install pyodbc on Linux

+0

我該如何安裝這些東西?我是否需要在requirements.txt中編寫它們?我嘗試過放入unixODBC-devel和gcc-C++。 – PriyalChaudhari

+0

您可以從命令行安裝它。如果你的操作系統是Ubuntu,[這個答案](https://stackoverflow.com/a/9087394/4115031)建議運行'sudo apt-get install unixodbc-dev'。 –

+0

我正在使用Windows,並沒有得到Windows的命令。嘗試使用PIP安裝它,但它說包沒有找到 – PriyalChaudhari