使用 numpy &Azure Web 角色中的 scipy [英] Use numpy & scipy in Azure web role

查看:12
本文介绍了使用 numpy &Azure Web 角色中的 scipy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑将 Azure 网站用于带有 Flask 的 Python 项目.我已经有一个使用此配置运行的测试站点.我正在使用 cPhyton 2.7;IronPhyton 在这个项目中绝对被丢弃,据我所知,Azure 中(还)不支持它.

不好的部分是我需要添加 scipy &numpy 对这个项目来说,这是一个不可避免的需求.据我所知,numpy 和 scipy 是已编译的非托管代码和 python 代码的混合体,它们不是标准 Azure 基础架构的一部分.

是否可以将 numpy/scipy 包添加到 Azure 网站?如果是,怎么办?

注意:我知道我可以为此使用虚拟机(是否为天蓝色),这是我的第二个选择,但我想做出明智的决定.

谢谢

解决方案

我能够将 Numpy 添加到我的 Azure Web App 站点.我相信我的方法也适用于 SciPy.

我假设您有一个本地存储库(我使用的是 GIT)并将其上传到您的 Azure 站点.我正在使用 Django,并且基础中有一个名为 requirements.txt 的文件,我敢打赌 Flask 也有这个文件.此文件的每一行都包含您要添加到安装中的包.

起初我只是简单地添加了一行Numpy",Azure 找到了一个包并尝试安装,但失败了.所以我的下一次尝试是从这个站点下载了一个wheel".whl 包:

http://www.lfd.uci.edu/~gohlke/pythonlibs/>

包括所有依赖项.下载 Numpy 和 SciPy 轮文件的相应文件(正确版本的 Python 和 32 位或 64 位,可以在 Azure 控制面板上选择)并将它们粘贴到您的基本目录中并将它们添加到您的项目中.现在一行到 requirements.txt 只包含文件名,如下所示:

numpy-1.9.2+mkl-cp27-none-win32.whl

提交并推送到 Azure 和 Voila!一切都安装正确.这也适用于该站点的 OpenCV 轮包.祝你好运!

I'm considering using an Azure web site for a Python project with Flask. I already have a test site running with this configuration. I'm using cPhyton 2.7; IronPhyton is absolutely discarded for this project and, as far as I know, it is not (yet) supported in Azure.

The bad part is that I need to add scipy & numpy to this project, this is an unavoidable requirement. As far as I know, numpy and scipy are a mix of compiled unmanaged code and python code and they're not part of the standard Azure infrastructure.

Is it possible to add numpy/scipy packages to an Azure web site? If it is, how?

Note: I know I could use a virtual machine for this (azure or not), that's my second option, but I would like to make an informed decision.

Thank you

解决方案

I was able to add Numpy to my Azure Web App site. I believe my method also works for SciPy.

I am assuming you have a local repository (I am using GIT) and upload it to your Azure site. I am using Django and there is a file called requirements.txt in the base, which I bet is there for Flask also. Each line of this file contains a package that you want added to the installation.

At first I simply added a line with "Numpy" to it and Azure found a package and tried to install but this failed. So my next attempt I downloaded a "wheel" .whl package from this site:

http://www.lfd.uci.edu/~gohlke/pythonlibs/

which includes all dependencies. Download the appropriate file (correct version of Python and 32 or 64 bit which can be chosen on Azure control panel) of the Numpy and SciPy wheel files and stick them into your base directory and add them to your project. Now a line to requirements.txt with just the file name, like this:

numpy-1.9.2+mkl-cp27-none-win32.whl

Commit and push to Azure and Voila! everything installs correctly. This also worked for me for the OpenCV wheel package at that site. Good luck!

这篇关于使用 numpy &Azure Web 角色中的 scipy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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