Python 网络托管:Numpy、Matplotlib、科学计算
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2080110/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python web hosting: Numpy, Matplotlib, Scientific Computing
提问by Steve Tjoa
I write scientific software in Numpy/Scipy/Matplotlib. Having developed applications on my home computer, I am now interested in writing simple web applications. Example: user uploads image or audio file, my program processes it using Numpy/Scipy, and output is displayed on the browser using Matplotlib, or perhaps the user can download a processed file.
我用 Numpy/Scipy/Matplotlib 编写科学软件。在我的家用计算机上开发了应用程序后,我现在对编写简单的 Web 应用程序感兴趣。示例:用户上传图像或音频文件,我的程序使用 Numpy/Scipy 处理它,并使用 Matplotlib 在浏览器上显示输出,或者用户可以下载处理过的文件。
I already pay for hosting that does have Python 2.4.3 installed, but no Numpy/Scipy. I don't have shell access via command line, either. Just drag-and-drop FTP. Pretty limited, but I can get simple Python/CGI scripts working.
我已经为安装了 Python 2.4.3 但没有安装 Numpy/Scipy 的托管付费。我也没有通过命令行访问 shell。只需拖放 FTP。相当有限,但我可以让简单的 Python/CGI 脚本工作。
Surprisingly, a web search revealed few suitable options for web hosting with these capabilities already built in. (Please guide me if I am wrong.) I am learning about the Google App Engine, but I still don't have a full understanding about its tools and limitations. What the web didtell me is that others have similar concerns.
令人惊讶的是,网络搜索发现很少有适合已内置这些功能的网络托管选项。(如果我错了,请指导我。)我正在学习 Google App Engine,但我仍然不完全了解它工具和限制。网络确实告诉我,其他人也有类似的担忧。
Hoping for solutions, I thought I would ask these simple questions to the awesome SO community:
希望得到解决方案,我想我会向很棒的 SO 社区提出这些简单的问题:
Is there a simple way of installing numpy (or any third-party package/library) onto my already hosted space? I know the Python path on my hosted space, and I know the relevant Python/Numpy directories on my home computer. Can I simply copy files over and have it work? Both local and remote systems run Ubuntu.
What hosting sites exist (either free or paid) which have Numpy/Matplotlib installed or, if not installed, the possibility of installing it? Are there any documented sites that you can reference with working applications, no matter how simple?
Can Google App Engine help me in any way? Or is it totally for something else? Have you or others used it to write scientific applications in Python/Numpy? If so, could you reference them?
有没有一种简单的方法可以将 numpy(或任何第三方包/库)安装到我已经托管的空间上?我知道我的托管空间上的 Python 路径,并且我知道我家计算机上的相关 Python/Numpy 目录。我可以简单地复制文件并让它工作吗?本地和远程系统都运行 Ubuntu。
哪些托管站点(免费或付费)安装了 Numpy/Matplotlib,或者如果未安装,是否有可能安装它?是否有任何文档站点可以在工作应用程序中引用,无论多么简单?
Google App Engine 能以任何方式帮助我吗?还是完全是为了别的?您或其他人是否使用它在 Python/Numpy 中编写科学应用程序?如果是这样,您可以参考它们吗?
Thank you for your help.
谢谢您的帮助。
EDIT: After the useful answers below, I bought the $20 plan at Slicehost, and I love it so far! (I first tried Amazon EC2. I must be stupid, but I just couldn't get it to work.) Setting up the Ubuntu server with Apache took mere hours (and I'm an Apache novice). It allows me to do exactly what I wanted with Python plus much more. I now have my own remote repository for version control, too. Thanks again!
编辑:在下面的有用答案之后,我在 Slicehost 购买了 20 美元的计划,到目前为止我很喜欢它!(我第一次尝试了 Amazon EC2。我一定是傻了,但我就是无法让它工作。)用 Apache 设置 Ubuntu 服务器只花了几个小时(我是 Apache 新手)。它让我可以用 Python 做我想做的事,还有更多。我现在也有自己的版本控制远程存储库。再次感谢!
EDIT 2: Nearly two years later, I tried Linode and EC2 (again). Linode is great. EC2 seemed easier this time around -- maybe it's just added experience, or maybe it's the improvements that Amazon made to the AWS management console. For those interested in Numpy/Scipy/Matplotlib/Audiolab, here is my Ubuntu cheat sheet whenever I launch an EC2 instance:
编辑 2:将近两年后,我(再次)尝试了 Linode 和 EC2。Linode 很棒。这一次 EC2 似乎更容易了——也许它只是增加了体验,或者也许是亚马逊对 AWS 管理控制台所做的改进。对于那些对 Numpy/Scipy/Matplotlib/Audiolab 感兴趣的人,这是我每次启动 EC2 实例时的 Ubuntu 备忘单:
ec2:~$ sudo aptitude install build-essential python-scipy ipython
python-matplotlib python-dev python-setuptools libsndfile-dev
libasound2-dev mysql-server python-mysqldb
Upload scikits.audiolab-0.11.0
ec2:~/scikits.audiolab-0.11.0$ sudo python setup.py install
ec2:~$ sudo rm -rf scikits.audiolab-0.11.0
ec2:~$ nano .ipython/ipy_user_conf.py
ip.ex('import matplotlib; matplotlib.use("Agg"); import scipy, pylab,
scipy.signal as sig, scipy.linalg as lin, scipy.sparse as spar,
os, sys, MySQLdb, boto; from scikits import audiolab')
import ipy_greedycompleter
import ipy_autoreload
采纳答案by Crast
1: Installing third party packages to hosted spaces
1:安装第三方包到托管空间
You can indeed install third party packages to your hosted space. If it's a pure python package, all that's needed is to unpack it to a directory and then add that directory to your PYTHONPATH environment variable or sys.path
.
您确实可以将第三方软件包安装到您的托管空间。如果它是一个纯 python 包,那么只需要将它解压到一个目录中,然后将该目录添加到你的 PYTHONPATH 环境变量或sys.path
.
This can be tiring to do often, and won't work easily for compiled modules. If you have shell access to your python host, the excellent virtualenvpackage allows you to do set up a private python environment with its own libraries.
经常这样做会很累,并且对于编译的模块来说不容易工作。如果您可以通过 shell 访问您的 python 主机,那么优秀的virtualenv包允许您使用自己的库来设置私有 python 环境。
To set up your virtualenv, you'll do something like this at the shell:
要设置您的 virtualenv,您将在 shell 中执行以下操作:
$ virtualenv $HOME/my_python
$ $HOME/my_python/bin/easy_install numpy
You can keep running easy_install for anything else you want to install in your personal python environment.
你可以继续运行 easy_install 来安装你想要在你的个人 python 环境中安装的任何东西。
Now, when you write your python scripts, you will want to use your private python interpreter, if that is possible:
现在,当您编写 Python 脚本时,如果可能,您将希望使用您的私有 Python 解释器:
#!/home/myuser/my_python/bin/python
import numpy
# script here
If your python env cannot be specified (such as if run by mod_wsgi), you will need to add it to the import path:
如果你的 python env 不能被指定(比如如果由 mod_wsgi 运行),你需要将它添加到导入路径:
import sys
sys.path.insert(0, '/home/myuser/my_python/lib/python2.5/site-packages')
import numpy
2: Hosting sites with numpy
2:使用 numpy 托管网站
I can't think of any hosting sites offhand which offer numpy pre-installed. However, Dreamhost/Bluehost for sharedhosts provide SSH access, and with shell access you can install numpy using the methods I described above. Any Virtual Private Server such as Linode/Slicehostwill allow you to install whatever you desire, as well.
我想不出任何提供 numpy 预安装的托管网站。但是,用于共享主机的 Dreamhost/Bluehost 提供 SSH 访问,通过 shell 访问,您可以使用我上面描述的方法安装 numpy。任何虚拟专用服务器(例如Linode/ Slicehost)也将允许您安装所需的任何内容。
3: AppEngine
3:应用引擎
As mentioned above, AppEngine will not allow you to install C extensions (but pure python ones do work) so it's unlikely numpy will work for you on there, since I suspect some of its features use C speedups.
如上所述,AppEngine 不允许您安装 C 扩展(但纯 python 可以工作),因此 numpy 不太可能在那里为您工作,因为我怀疑它的某些功能使用 C 加速。
回答by Alex Martelli
App Engine does not support any of numpy, scipy, or matplotlib, alas.
App Engine 不支持任何 numpy、scipy 或 matplotlib,唉。
If you know exactly what OS and CPU your host is using, you could make an identical installation for yourself, download and install the same version of Python they're using, download the sources of packages you require and build them into .so
(or .pyd
, depending on the platform) files, and upload those -- sounds like a real tour de force.
如果您确切地知道您的主机正在使用什么操作系统和 CPU,您可以为自己进行相同的安装,下载并安装他们正在使用的相同版本的 Python,下载您需要的软件包源并将它们构建到.so
(或.pyd
,取决于在平台上)文件,然后上传这些文件 - 听起来像一个真正的杰作。
Any of the many, manysites that offer normal virtual hosting (a virtual machine, typically Linux, with modest HW resources, but root privileges for you, ssh shell access, and a gcc
you can use in particular) will be mucheasier to work with -- essentially, you'll download and install the software you need just about the same way you'd do on your own Linux workstation!
提供普通虚拟主机(虚拟机,通常是 Linux,具有适度的硬件资源,但为您提供 root 权限、ssh shell 访问以及您可以特别使用的一个)的许多站点中的任何一个都将更容易使用-- 本质上,您将下载和安装所需的软件,就像在您自己的 Linux 工作站上一样!gcc
回答by Giles Thomas
2 What hosting sites exist (either free or paid) which have Numpy/Matplotlib installed
2 安装了 Numpy/Matplotlib 的托管站点(免费或付费)
PythonAnywhereoffers web hosting and a simple in-browser IDE; lots of Python packages (including NumPy and Matplotlib) are pre-installed. There's a free plan that you can use to play around, and "Premium" and "Hosting" accounts with more features are $5 and $10/month respectively.
PythonAnywhere提供网络托管和简单的浏览器内 IDE;预装了许多 Python 包(包括 NumPy 和 Matplotlib)。有一个免费计划可供您使用,具有更多功能的“高级”和“托管”帐户分别为每月 5 美元和 10 美元。
Full disclosure: I work there...
完全披露:我在那里工作......
回答by klimaat
I do not have privledges yet to comment but I can provide an "answer".
我还没有发表评论的特权,但我可以提供一个“答案”。
3: AppEngine
3:应用引擎
Numpy is now available on Google App Engine: https://code.google.com/p/googleappengine/issues/detail?id=190
Numpy 现在可在 Google App Engine 上使用:https: //code.google.com/p/googleappengine/issues/detail?id=190
However, matplotlib is still waiting: http://code.google.com/p/googleappengine/issues/detail?id=482Perhaps more people starring this issue will make it happen.
然而,matplotlib 仍在等待:http: //code.google.com/p/googleappengine/issues/detail?id=482 也许更多人主演这个问题会实现它。
I will note that svgfig is an option as it is pure python: http://code.google.com/p/svgfig/
我会注意到 svgfig 是一个选项,因为它是纯 python:http: //code.google.com/p/svgfig/
Update:
更新:
Turns out matplotlib is now available: https://developers.google.com/appengine/docs/python/tools/libraries27#matplotlib
原来 matplotlib 现在可用:https: //developers.google.com/appengine/docs/python/tools/libraries27#matplotlib