44

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.

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.

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 did tell me is that others have similar concerns.

Hoping for solutions, I thought I would ask these simple questions to the awesome SO community:

  1. 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.

  2. 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?

  3. 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?

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!

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:

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
4

4 回答 4

17

1:将第三方包安装到托管空间

您确实可以将第三方软件包安装到您的托管空间。如果它是纯 python 包,只需将其解压缩到一个目录,然后将该目录添加到您的 PYTHONPATH 环境变量或sys.path.

经常这样做会很累,并且对于已编译的模块也不容易工作。如果你有对你的 python 主机的 shell 访问,优秀的virtualenv包允许你用它自己的库设置一个私有的 python 环境。

要设置您的 virtualenv,您将在 shell 中执行以下操作:

$ virtualenv $HOME/my_python
$ $HOME/my_python/bin/easy_install numpy

您可以继续运行 easy_install 以在您的个人 python 环境中安装任何其他内容。

现在,当你编写你的 python 脚本时,如果可能的话,你会想要使用你的私有 python 解释器:

#!/home/myuser/my_python/bin/python

import numpy

# script here

如果无法指定您的 python 环境(例如,如果由 mod_wsgi 运行),则需要将其添加到导入路径:

import sys
sys.path.insert(0, '/home/myuser/my_python/lib/python2.5/site-packages')

import numpy

2:使用 numpy 托管网站

我想不出任何提供 numpy 预装的托管网站。但是,共享主机的Dreamhost /Bluehost 提供 SSH 访问,并且通过 shell 访问,您可以使用我上面描述的方法安装 numpy。任何虚拟专用服务器(例如Linode / Slicehost )也允许您安装任何您想要的东西。

3:应用引擎

如上所述,AppEngine 将不允许您安装 C 扩展(但纯 python 确实可以),因此 numpy 不太可能在那里为您工作,因为我怀疑它的某些功能使用 C 加速。

于 2010-01-17T07:10:09.700 回答
13

App Engine does not support any of numpy, scipy, or matplotlib, alas.

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.

Any of the many, many sites 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 much easier 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!

于 2010-01-17T06:04:59.807 回答
9

2 存在哪些安装了 Numpy/Matplotlib 的托管站点(免费或付费)

PythonAnywhere提供网络托管和简单的浏览器内 IDE;预装了很多 Python 包(包括 NumPy 和 Matplotlib)。有一个免费计划可供您玩,具有更多功能的“高级”和“托管”帐户分别为每月 5 美元和 10 美元。

全面披露:我在那里工作......

于 2012-05-18T17:20:31.357 回答
6

我还没有发表评论的特权,但我可以提供一个“答案”。

3:应用引擎

Numpy 现在可以在 Google App Engine 上使用: https ://code.google.com/p/googleappengine/issues/detail?id=190

但是,matplotlib 仍在等待: http ://code.google.com/p/googleappengine/issues/detail?id=482 也许更多人主演这个问题会实现。

我会注意到 svgfig 是一个选项,因为它是纯 python: http ://code.google.com/p/svgfig/

更新:

原来 matplotlib 现在可用: https ://developers.google.com/appengine/docs/python/tools/libraries27#matplotlib

于 2012-03-06T19:10:52.127 回答