

 从补丁 198 开始，Amazon Redshift 将不再支持创建新的 Python UDF。现有的 Python UDF 将继续正常运行至 2026 年 6 月 30 日。有关更多信息，请参阅[博客文章](https://www.amazonaws.cn/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)。

# 适用于 UDF 的 Python 语言支持
<a name="udf-python-language-support"></a>

您可以基于 Python 编程语言创建自定义 UDF。[Python 2.7 标准库](https://docs.python.org/2/library/index.html)可以在 UDF 中使用，但以下模块除外：
+ ScrolledText
+ Tix
+ Tkinter
+ tk
+ turtle
+ smtpd

除 Python 标准库之外，以下模块也是 Amazon Redshift 实施的一部分：
+ [numpy 1.8.2](http://www.numpy.org/)
+ [pandas 0.14.1](https://pandas.pydata.org/)
+ [python-dateutil 2.2](https://dateutil.readthedocs.org/en/latest/)
+ [pytz 2014.7](https://pypi.org/project/pytz/2014.7/)
+ [scipy 0.12.1](https://www.scipy.org/)
+ [six 1.3.0](https://pypi.org/project/six/1.3.0/)
+ [wsgiref 0.1.2](https://pypi.python.org/pypi/wsgiref)

您也可以通过执行 [CREATE LIBRARY](r_CREATE_LIBRARY.md) 命令来导入您自己的自定义 Python 模块并使其在 UDF 中可用。有关更多信息，请参阅 [示例：导入自定义 Python 库模块](udf-importing-custom-python-library-modules.md)。

**重要**  
Amazon Redshift 将阻止通过 UDF 对文件系统进行的所有网络访问和写入访问。

**注意**  
Python 3 不适用于 Python UDF。要获得 Python 3 对 Amazon Redshift UDF 的支持，请改用 [标量 Lambda UDF](udf-creating-a-lambda-sql-udf.md)。