2017-07-22 85 views
1

我正在部署到Azure应用程序服务。应用程序设置为:Windows主机,32位和Python 3.4。我还有其他所有工作,但是当我尝试切换到使用Postgres DB时,我遇到了一个问题。当pip尝试从requirements.txt安装需求时,它无法安装psycopg2。错误是:如何在Azure应用服务Windows Web应用上安装psycopg2?

> env\scripts\pip install psycopg2 
D:\home\site\wwwroot 
Downloading/unpacking psycopg2 
    Running setup.py (path:D:\home\site\wwwroot\env\build\psycopg2\setup.py) egg_info for package psycopg2 
    Error: pg_config executable not found. 

显然,这是因为它正在尝试编译PG库,但我不明白为什么它正试图当有自称是在PyPI将页面上列出的车轮编译CP34-win32的。

我试图犯轮库,然后直接安装(通过deploy.cmd env\scripts\pip install wheelhouse\psycopg2-2.7.1-cp34-cp34m-win32.whl)部署在轮但这会导致这个错误:

> env\scripts\pip install wheelhouse\psycopg2-2.7.1-cp34-cp34m-win32.whl 
D:\home\site\wwwroot 
psycopg2-2.7.1-cp34-cp34m-win32.whl is not a supported wheel on this platform. 

Storing debug log for failure in D:\home\pip\pip.log 


> type D:\home\pip\pip.log 
D:\home\site\wwwroot 
------------------------------------------------------------ 

D:\home\site\wwwroot\env\scripts\pip run on 07/22/17 17:47:25 

psycopg2-2.7.1-cp34-cp34m-win32.whl is not a supported wheel on this platform. 

Exception information: 

Traceback (most recent call last): 

    File "D:\home\site\wwwroot\env\lib\site-packages\pip\basecommand.py", line 122, in main 

    status = self.run(options, args) 

    File "D:\home\site\wwwroot\env\lib\site-packages\pip\commands\install.py", line 257, in run 

    InstallRequirement.from_line(name, None)) 

    File "D:\home\site\wwwroot\env\lib\site-packages\pip\req.py", line 167, in from_line 

    raise UnsupportedWheel("%s is not a supported wheel on this platform." % wheel.filename) 

pip.exceptions.UnsupportedWheel: psycopg2-2.7.1-cp34-cp34m-win32.whl is not a supported wheel on this platform. 
+0

试轮x64包??? – 4c74356b41

回答

1

问题来源于这样的事实是, Azure提供的Python 3.4版本非常陈旧。可用的pip版本不够新,无法成功安装psycopg2轮。试图运行pip install -U pip没有帮助。它导致损坏的pip安装,并且env文件夹必须被删除并重新创建。

我的这个问题的解决方法是安装Python 3.6.1 32位作为“扩展”。这些扩展可在Azure的Web应用程序设置的左窗格中找到,并允许选择任何版本的Python。一旦扩展被激活,一个新的Python文件夹就可以在D:\ home \ python36中使用(例如)。从那里,运行pip install psycopg2工作没有任何问题。

剩下的唯一问题是我无法使用新的Python 3.6运行virtualenv,因此我必须重新调整部署脚本(deploy.cmd)和web.config以引用D中的Python可执行文件:\ home \ python36而不是D:\ home \ wwwroot \ env \ scripts。还删除了deploy.cmd中检测requirements.txt和runtime.txt的一堆逻辑,因为该样板逻辑不是必需的。

相关问题