numpy和scipy_适用于Numpy,Scipy和Scikit的Heroku Buildpack学习

巫马令
2023-12-01

numpy和scipy

(TLDR: https://github.com/dbrgn/heroku-buildpack-python-sklearn)

(TLDR: https//github.com/dbrgn/heroku-buildpack-python-sklearn

背景 (Background)

At Webrepublic we just launched a Python based system that among other things does comparison of large texts using tf-idf vectors in a multi-dimensional vector space and measuring the cosine similarity between them (see http://stackoverflow.com/a/8897648/284318). For this, we needed scikit-learn.

Webrepublic,我们刚刚启动了一个基于Python的系统,该系统除其他功能外,还使用多维矢量空间中的tf-idf矢量对大型文本进行比较,并测量它们之间的余弦相似度(请参见http://stackoverflow.com/a/8897648) / 284318 )。 为此,我们需要scikit-learn

During the deployment process, I discovered that one does not simply deploy. There were different issues with it. First of all, Scipy needs Numpy to be available at setup.py parse time. If you just install Numpy and Scipy using requirements.txt, Numpy won’t yet be installed at the time the Scipy setup.py is processed. (Note that this has been fixed in current versions of Scipy.)

在部署过程中,我发现并不仅仅是部署。 有不同的问题。 首先,Scipy需要Numpy在setup.py解析时可用。 如果仅使用requirements.txt安装Numpy和Scipy,则在处理Scipy setup.py时尚未安装Numpy。 (请注意,这已在当前版本的Scipy中修复。)

Another issue was that a Fortran compiler and different libraries are needed to build Scipy, all of which are not available on Heroku.

另一个问题是,构建Scipy需要使用Fortran编译器和其他库,所有这些在Heroku上均不可用。

解决问题的尝试 (Problem Solving Attempts)

The first thing I found while looking for a solution was wyn/heroku-buildpack-python, but I couldn’t quite get it to work. The second thing I found was ToonTimbermont/heroku-buildpack-python, a fork of wyn’s fork that solves some of the issues.

我在寻找解决方案时发现的第一件事是wyn / heroku-buildpack-python ,但是我无法完全正常工作。 我发现的第二件事是ToonTimbermont / heroku-buildpack-python ,它是解决了一些问题的wyn叉子的叉子。

(I also played around with Kenneth Reitz’s anaconda buildpack, but didn’t really get it to work the way I wanted it.)

(我也曾与Kenneth Reitz的anaconda buildpack一起玩,但是并没有真正按照我想要的方式工作。)

By combining the work of both developers, using the precompiled binaries by wyn and adding some code I managed to rebase all the changes on top of Heroku’s current buildpack. This solves some issues/bugs with older versions of Pip.

通过结合两个开发人员的工作,使用wyn预编译的二进制文件并添加一些代码,我设法将所有更改重新基于Heroku当前的buildpack。 这解决了旧版Pip的一些问题/错误。

Another change I made was that the dependencies can be stated in requirements.txt as usual, instead of requiring a setup.py file.

我进行的另一项更改是,可以像往常一样在requirements.txt中声明依赖项,而不需要setup.py文件。

You can find the buildpack at https://github.com/dbrgn/heroku-buildpack-python-sklearn. All the changes against the official Heroku buildpack at the time of this writing have been condensed in a single commit.

您可以在https://github.com/dbrgn/heroku-buildpack-python-sklearn上找到buildpack。 在撰写本文时,对正式的Heroku buildpack的所有更改都在一次提交中进行了汇总

用法 (Usage)

The process to use the buildpack is as straightforward as with any other buildpack. For a new app:

使用buildpack的过程与使用任何其他buildpack一样简单。 对于新应用:


heroku create --buildpack https://github.com/dbrgn/heroku-buildpack-python-sklearn/

For an existing app:

对于现有应用程序:


heroku config:set BUILDPACK_URL=https://github.com/dbrgn/heroku-buildpack-python-sklearn/

If you have any questions or problems, feel free to leave a comment or open an issue on Github.

如果您有任何疑问或问题,请随时在Github上发表评论或打开问题

Update 8/4/13: It is important that you only use versions of Numpy and Scipy that are available as precompiled binaries. For list of available versions, see the npscipy-binaries repo.

13年8月4日更新:仅使用预编译二进制文件形式的Numpy和Scipy版本很重要。 有关可用版本的列表,请参见npscipy-binaries repo

翻译自: https://www.pybloggers.com/2013/06/heroku-buildpack-for-numpy-scipy-and-scikit-learn/

numpy和scipy

 类似资料: