简体   繁体   中英

Installing psycopg2 in an Azure Web App

I use Heroku to host a Django web app with a postgres back-end. I'm now looking to migrate this web app to Azure, taking advantage of a great deal Azure recently offered me.

I've made an Azure Web App, and hosted the postgres DB on a separate Azure VM.

When I try to set up Contiguous Integration in the Azure Web app (connecting it to my github account for the purpose), I end up hitting the error: Running setup.py (path:D:\\home\\site\\wwwroot\\env\\build\\psycopg2\\setup.py) egg_info for package psycopg2 Error: pg_config executable not found.

Ie, while installing from requirements.txt, it fails on trying to install psycopg2 (postgresql). I'm trying to figure out what to do next from this point. According to this , I'm supposed to run:

pip install git+https://github.com/nwcell/psycopg2-windows.git@win64-py27#egg=psycopg2

Now I can't run that in the console I have in my https://webapp.scm.azurewebsites.net ; pip is not recognized. Should I edit my requirement.txt directly, and include that line instead of psycopg2==2.6 ? In which case, since it's my master repository, I'll have to remember not to push this new requirements.txt mistakenly to Heroku.

There are two key points as your missing.

First, Azure Webapps normally run on the 32-bit system platform. If you have to use the 64-bit package, you need to update the Basic or Standard mode for your apps and switch the 64-bit platform, see below in the tab Configure of Azure WebApps.

在此处输入图片说明

So you shoule install the psycopg2 version git+https://github.com/nwcell/psycopg2-windows.git@win32-py27#egg=psycopg2

Second, you can run the pip command in the path D:\\Python27\\Scripts> at Kudu. But unfortunately, you can't directly install the python package required a compiler thru pip tool. Please refer to the section "Troubleshooting - Package Installation" of the document https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-configure/#troubleshooting---package-installation to know how to handle it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM