📝

Lambda の Python ランタイムにデフォルトでインストールされているライブラリを確認してみた

に公開

Lambda の各ランタイムにデフォルトでインストールされているライブラリを確認する方法
上記ブログで Python 3.13 にデフォルトでインストールされているライブラリを確認しましたが、以下のランタイムでも確認してみました。

  • Python 3.13
  • Python 3.12
  • Python 3.11
  • Python 3.10
  • Python 3.9
  • Python 3.8

1. 関数の作成

Lambda ランタイム - AWS Lambda

Lambda コンソールで非推奨になったランタイムを使用して新しい関数を作成または更新できなくなりました。AWS CLI、AWS SAM、または AWS CloudFormation を使用して関数を引き続き作成および更新できます。

Python 3.8 はコンソールから作成できないため AWS CLI で作成しました。

$ cat > lambda_function.py << 'EOF'
import sys
import pkgutil

def lambda_handler(event, context):
    
    modules = []
    for importer, modname, ispkg in pkgutil.iter_modules():
        modules.append(modname)

    for module in sorted(modules):
        print(module)
EOF

$ zip function.zip lambda_function.py

$ aws lambda create-function \
--function-name python38 \
--runtime python3.8 \
--role lambda-role-arn \
--handler lambda_function.lambda_handler \
--zip-file fileb://function.zip

2. 各ランタイムに共通でインストールされているライブラリ

__future__
_asyncio
_bisect
_blake2
_bz2
_codecs_cn
_codecs_hk
_codecs_iso2022
_codecs_jp
_codecs_kr
_codecs_tw
_collections_abc
_compat_pickle
_compression
_contextvars
_csv
_ctypes
_ctypes_test
_curses
_curses_panel
_datetime
_dbm
_decimal
_elementtree
_gdbm
_hashlib
_heapq
_json
_lsprof
_lzma
_markupbase
_md5
_multibytecodec
_multiprocessing
_opcode
_osx_support
_pickle
_posixshmem
_posixsubprocess
_py_abc
_pydecimal
_pyio
_queue
_random
_sha1
_sha3
_sitebuiltins
_socket
_sqlite3
_ssl
_statistics
_strptime
_struct
_sysconfigdata__linux_x86_64-linux-gnu
_testbuffer
_testcapi
_testimportmultiple
_testinternalcapi
_testmultiphase
_threading_local
_weakrefset
_xxtestfuzz
abc
antigravity
argparse
array
ast
asyncio
base64
bdb
binascii
bisect
bootstrap
boto3
botocore
bz2
cProfile
calendar
cmath
cmd
code
codecs
codeop
collections
colorsys
compileall
concurrent
configparser
contextlib
contextvars
copy
copyreg
crypt
csv
ctypes
curses
dataclasses
datetime
dateutil
dbm
decimal
difflib
dis
doctest
email
encodings
ensurepip
enum
fcntl
filecmp
fileinput
fnmatch
fractions
ftplib
functools
genericpath
getopt
getpass
gettext
glob
grp
gzip
hashlib
heapq
hmac
html
http
idlelib
imaplib
importlib
inspect
io
ipaddress
jmespath
json
keyword
lambda_function
linecache
locale
logging
lzma
mailbox
math
mimetypes
mmap
modulefinder
multiprocessing
netrc
ntpath
nturl2path
numbers
opcode
operator
optparse
os
pathlib
pdb
pickle
pickletools
pip
pkgutil
platform
plistlib
poplib
posixpath
pprint
profile
pstats
pty
py_compile
pyclbr
pydoc
pydoc_data
pyexpat
queue
quopri
random
re
readline
reprlib
resource
rlcompleter
runpy
s3transfer
sched
secrets
select
selectors
shelve
shlex
shutil
signal
site
six
smtplib
socket
socketserver
sqlite3
sre_compile
sre_constants
sre_parse
ssl
stat
statistics
string
stringprep
struct
subprocess
symtable
sysconfig
syslog
tabnanny
tarfile
tempfile
termios
test
textwrap
this
threading
timeit
tkinter
token
tokenize
trace
traceback
tracemalloc
tty
turtle
turtledemo
types
typing
unicodedata
unittest
urllib
urllib3
uuid
venv
warnings
wave
weakref
webbrowser
wsgiref
xml
xmlrpc
xxlimited
zipapp
zipfile
zipimport
zlib

3. Python 3.13 にはインストールされていないライブラリ

_bootlocale
_crypt
_distutils_hack
_dummy_thread
_sha256
_sha512
_xxsubinterpreters
aifc
asynchat
asyncore
audioop
binhex
cgi
cgitb
chunk
crypt
distutils
dummy_threading
formatter
imghdr
imp
lambda_internal
lambda_literals
lambda_runtime_client
lambda_runtime_exception
lambda_runtime_log_utils
lambda_runtime_marshaller
lib2to3
mailcap
nis
nntplib
ossaudiodev
parser
pipes
pkg_resources
rapid_client
setup
setuptools
smtpd
sndhdr
spwd
sunau
symbol
telnetlib
uu
xdrlib
_bootsubprocess
_typing
_xxinterpchannels

4. Python 3.12 にはインストールされていないライブラリ

_bootlocale
_distutils_hack
_dummy_thread
_sha256
_sha512
asynchat
asyncore
binhex
distutils
dummy_threading
formatter
imp
lambda_internal
lambda_literals
lambda_runtime_client
lambda_runtime_exception
lambda_runtime_log_utils
lambda_runtime_marshaller
nis
parser
pkg_resources
rapid_client
setup
setuptools
smtpd
symbol
_bootsubprocess
_typing

5. Python 3.11 にはインストールされていないライブラリ

_bootlocale
_dummy_thread
binhex
distutils
formatter
lambda_internal
lambda_literals
lambda_runtime_client
lambda_runtime_exception
lambda_runtime_log_utils
lambda_runtime_marshaller
parser
pkg_resources
rapid_client
setup
symbol
_bootsubprocess
_typing
_pydatetime
_pylong
_testsinglephase
_xxinterpchannels
xxsubtype
_android_support
_apple_support
_colorize
_interpchannels
_interpqueues
_interpreters
_ios_support
_opcode_metadata
_pydatetime
_pylong
_pyrepl
_sha2
_testclinic_limited
_testexternalinspection
_testlimitedcapi
_testsinglephase

6. Python 3.10 にはインストールされていないライブラリ

_bootlocale
_dummy_thread
dummy_threading
formatter
lambda_internal
lambda_literals
lambda_runtime_client
lambda_runtime_exception
lambda_runtime_log_utils
lambda_runtime_marshaller
parser
rapid_client
setup
symbol
__hello__
__phello__
_typing
tomllib
_pydatetime
_pylong
_sha2
_testsinglephase
_xxinterpchannels
xxsubtype
_android_support
_apple_support
_colorize
_interpchannels
_interpqueues
_interpreters
_ios_support
_opcode_metadata
_pydatetime
_pylong
_pyrepl
_testclinic_limited
_testexternalinspection
_testlimitedcapi
_testsinglephase

7. Python 3.9 にはインストールされていないライブラリ

_dummy_thread
dummy_threading
lambda_internal
lambda_literals
lambda_runtime_client
lambda_runtime_exception
lambda_runtime_log_utils
lambda_runtime_marshaller
rapid_client
setup
_testclinic
xxlimited_35
__hello__
__phello__
_testclinic
_typing
tomllib
_pydatetime
_pylong
_sha2
_testclinic
_testsinglephase
_xxinterpchannels
xxsubtype
_android_support
_apple_support
_colorize
_interpchannels
_interpqueues
_interpreters
_ios_support
_opcode_metadata
_pyrepl
_testclinic_limited
_testexternalinspection
_testlimitedcapi
_testsinglephase

8. Python 3.8 にはインストールされていないライブラリ

_aix_support
_bootsubprocess
_zoneinfo
awslambdaric
graphlib
runtime_client
simplejson
snapshot_restore_py
zoneinfo
_testclinic
xxlimited_35
__hello__
__phello__
_typing
tomllib
_pydatetime
_pylong
_sha2
_testsinglephase
_xxinterpchannels
xxsubtype
_android_support
_apple_support
_colorize
_interpchannels
_interpqueues
_interpreters
_ios_support
_opcode_metadata
_pyrepl
_testclinic_limited
_testexternalinspection
_testlimitedcapi
_testsinglephase

まとめ

今回は Lambda の Python ランタイムにデフォルトでインストールされているライブラリを確認してみました。
どなたかの参考になれば幸いです。

参考資料

Discussion