AI Chat に課金をしているので、サブスクが多くなりすぎたので、Google Colab Pro を解約しました。Google Colab のインターフェースは便利な事も多いので、
今後はローカルランタイムを使っていこうと思い、ChatGPT に次のような質問をしました。
オレ
Google colab をローカルランタイム(Windows WSL) で使用しています。(Python 3.12.3)
venv 環境を使い pip install jupyter で Jupyter Notebook をインストールし
jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com' --NotebookApp.port_retries=0 --notebook-dir="" --no-browser --allow-root --NotebookApp.token=${TOKEN} --NotebookApp.disable_check_xsrf=True --port=8888
として起動しています。
正常に使えてはいますが、既存の Colab ノートブックを実行する際、ディフォルトでインストールされておらず新たにインストールしなければならないライブラリが多いです。
コンフリクトが起きるため、完全には同じにはできなと思いますが、一般に公開されている Colab ノートブックに近い状態にしたいのでそのための requirements.txt を作成してください。
ない、Bug Fix は取り込みたいので、あまり細かいバージョンまで指定しない方が好みです。
現在の Colab の本来の環境はこうなっています。
python --version
Python 3.10.12
pip freeze
absl-py==1.4.0
【中略】
zipp==3.20.0
ChatGPT 4o
To create a requirements.txt file that closely matches the Colab environment, here is a general approach that avoids specifying overly detailed versions, aiming to maintain compatibility without causing conflicts:
absl-py
【中略】
zipp
This requirements.txt file includes all the libraries listed in the Colab environment, without specifying the exact versions, allowing you to install the latest compatible versions of each library. This should help you get an environment that's very close to the one in Colab.
You can use this file by running the following command in your local WSL environment:
pip install -r requirements.txt
オレ
途中でエラーが出てインストールできません。
dbus-gmain| Compiler for C supports arguments -Wpointer-sign: YES (cached)
dbus-gmain| Compiler for C supports arguments -Wstrict-prototypes: YES (cached)
dbus-gmain| Did not find pkg-config by name 'pkg-config'
dbus-gmain| Found pkg-config: NO
dbus-gmain| Did not find CMake 'cmake'
dbus-gmain| Found CMake: NO
dbus-gmain| Run-time dependency dbus-1 found: NO
../subprojects/dbus-gmain/meson.build:107:11: ERROR: Dependency lookup for dbus-1 with method 'pkgconfig' failed: Pkg-config for machine host machine not found. Giving up.
A full log can be found at /tmp/pip-install-ndeijvsj/dbus-python_2121a74eb78b4533aed581f1e5d1a404/.mesonpy-1vrofkvp/meson-logs/meson-log.txt
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
ChatGPT 4o
dbus-python など、特定のシステム依存のあるパッケージが問題となっているようです。そこで、インストール時に問題が発生しやすいパッケージを除外した requirements.txt を作成します。このファイルでは、エラーが発生しにくい一般的なライブラリを優先しています。
以下が修正後の requirements.txt です:
absl-py
【中略】
zipp
この requirements.txt は、dbus-python や launchpadlib のようなシステム依存の強いライブラリを除外しています。このファイルを使用して、次のコマンドでパッケージをインストールしてみてください。
pip install -r requirements.txt
オレ
依然として途中でエラーが出てインストールできません。
Collecting google-cloud-translate (from -r requirements2.txt (line 146))
Downloading google_cloud_translate-3.16.0-py2.py3-none-any.whl.metadata (5.3 kB)
ERROR: Ignored the following versions that require a different python version: 0.0.1a1 Requires-Python >=3.6, <3.10; 0.0.1a2 Requires-Python >=3.6, <3.10; 0.1.0 Requires-Python >=3.6, <3.10; 0.1.1 Requires-Python >=3.6, <3.10; 0.2.0 Requires-Python >=3.6, <3.10; 0.3.0 Requires-Python >=3.6, <3.11; 0.3.1 Requires-Python >=3.6, <3.11; 0.4.0 Requires-Python >=3.6, <3.11; 1.0.0 Requires-Python >=3.6, <3.11; 1.0.1 Requires-Python >=3.6, <3.11; 1.0.2 Requires-Python >=3.6, <3.11; 1.0.3 Requires-Python >=3.7, <3.11; 2.10.0 Requires-Python >=3.6, <3.10; 2.11.0 Requires-Python >=3.6, <3.10; 2.12.0 Requires-Python >=3.6, <3.10; 2.13.0 Requires-Python >=3.6, <3.10; 2.13.1 Requires-Python >=3.6, <3.10; 2.14.0 Requires-Python >=3.6, <3.10; 2.15.0 Requires-Python >=3.6, <3.10; 2.16.0 Requires-Python >=3.6, <3.10; 2.16.1 Requires-Python >=3.6, <3.10; 2.17.0 Requires-Python >=3.6, <3.10; 2.18.0 Requires-Python >=3.6, <3.10; 2.19.0 Requires-Python >=3.6, <3.10; 2.20.0 Requires-Python >=3.6, <3.10; 2.21.0 Requires-Python >=3.6, <3.10; 2.22.0 Requires-Python >=3.6, <3.10; 2.22.1 Requires-Python >=3.6, <3.10; 2.23.0 Requires-Python >=3.6, <3.10; 2.23.1 Requires-Python >=3.6, <3.10; 2.23.2 Requires-Python >=3.6, <3.10; 2.23.3 Requires-Python >=3.6, <3.10; 2.24.0 Requires-Python >=3.6, <3.10; 2.24.1 Requires-Python >=3.6, <3.10; 2.25.0 Requires-Python >=3.6, <3.10; 2.25.1 Requires-Python >=3.6, <3.10; 2.25.2 Requires-Python >=3.6, <3.10; 2.26.0 Requires-Python >=3.6, <3.10; 2.27.0 Requires-Python >=3.6, <3.10; 2.27.1 Requires-Python >=3.6, <3.10; 2.28.0 Requires-Python >=3.6, <3.10; 2.28.1 Requires-Python >=3.6, <3.10; 2.29.0 Requires-Python >=3.6, <3.10; 2.30.0 Requires-Python >=3.6, <3.11; 2.30.1 Requires-Python >=3.6, <3.11; 2.31.0 Requires-Python >=3.6, <3.11; 2.32.0 Requires-Python >=3.6, <3.11; 2.33.0 Requires-Python >=3.6, <3.11; 2.34.0 Requires-Python >=3.6, <3.11; 2.34.1 Requires-Python >=3.6, <3.11; 2.34.2 Requires-Python >=3.6, <3.11; 2.34.3 Requires-Python >=3.6, <3.11; 2.34.4 Requires-Python >=3.6, <3.11; 2.6.2 Requires-Python >=3.6, <3.9; 2.7.0 Requires-Python >=3.6, <3.10; 2.8.0 Requires-Python >=3.6, <3.10; 2.9.0 Requires-Python >=3.6, <3.10; 3.0.0 Requires-Python >=3.6, <3.11; 3.0.0b1 Requires-Python >=3.6, <3.11; 3.0.1 Requires-Python >=3.6, <3.11; 3.1.0 Requires-Python >=3.6, <3.11; 3.2.0 Requires-Python >=3.6, <3.11; 3.3.0 Requires-Python >=3.7, <3.11; 3.3.1 Requires-Python >=3.7, <3.11; 3.3.2 Requires-Python >=3.7, <3.11; 3.3.3 Requires-Python >=3.7, <3.11; 3.3.5 Requires-Python >=3.7, <3.11; 3.3.6 Requires-Python >=3.7, <3.11
ERROR: Could not find a version that satisfies the requirement google-colab (from versions: none)
ERROR: No matching distribution found for google-colab
エラーが出ない範囲で妥協した requirements.txt を作成してください。
なお、ローカル環境なので Google Drive をマウントすることはありません。
ChatGPT 4o
以下の requirements.txt では、ローカル環境でエラーが出やすいライブラリを除外し、Python 3.12 で動作可能なライブラリを中心にリストアップしました。また、Google Drive のマウントは不要とのことなので、google-colab や google-cloud-translate などのライブラリも除外しています。
absl-py
【中略】
zipp
この requirements.txt ファイルでは、依存関係のエラーが発生しにくく、ローカル環境での利用に適したライブラリをリストアップしています。このファイルを使って再度インストールをお試しください。
pip install -r requirements.txt
こうった、エラー結果を貼って修正させて、またそれを使ってという繰り返しを10回移譲した後にやった、エラーの出ない妥協版の
requirements.txt が出来ました。
absl-py
accelerate
aiohttp
aiosignal
alabaster
albucore
albumentations
altair
annotated-types
anyio
argon2-cffi
argon2-cffi-bindings
array_record
arviz
asn1crypto
astropy
astropy-iers-data
astunparse
async-timeout
atpublic
attrs
audioread
autograd
babel
backcall
beautifulsoup4
bidict
bigframes
bleach
blinker
blis
blosc2
bokeh
branca
build
CacheControl
cachetools
catalogue
certifi
cffi
chardet
charset-normalizer
chex
clarabel
click
click-plugins
cligj
cloudpathlib
cloudpickle
cmake
cmdstanpy
colorcet
colorlover
colour
community
confection
cons
contextlib2
contourpy
cryptography
cuda-python
cufflinks
cupy-cuda12x
cvxopt
cvxpy
cycler
cymem
Cython
dask
datascience
db-dtypes
debugpy
decorator
defusedxml
distributed
distro
dm-tree
docstring_parser
docutils
dopamine_rl
duckdb
easydict
ecos
editdistance
eerepr
einops
entrypoints
et-xmlfile
etils
etuples
eval_type_backport
exceptiongroup
fastai
fastcore
fastdownload
fastjsonschema
fastprogress
fastrlock
filelock
fiona
firebase-admin
Flask
flatbuffers
flax
folium
fonttools
frozendict
frozenlist
fsspec
future
gast
gcsfs
gdown
geemap
gensim
geocoder
geographiclib
geopandas
geopy
gin-config
glob2
google-api-core
google-api-python-client
google-auth
google-auth-httplib2
google-auth-oauthlib
google-cloud-aiplatform
google-cloud-bigquery
google-cloud-bigquery-connection
google-cloud-bigquery-storage
google-cloud-bigtable
google-cloud-core
google-cloud-datastore
google-cloud-firestore
google-cloud-functions
google-cloud-iam
google-cloud-language
google-cloud-pubsub
google-cloud-resource-manager
google-cloud-storage
google-cloud-translate
google-crc32c
google-generativeai
google-pasta
google-resumable-media
googleapis-common-protos
googledrivedownloader
graphviz
greenlet
grpc-google-iam-v1
grpcio
grpcio-status
gspread
gspread-dataframe
gym
gym-notices
h5netcdf
h5py
holidays
holoviews
html5lib
httpimport
httplib2
huggingface-hub
humanize
hyperopt
ibis-framework
idna
imageio
imageio-ffmpeg
imagesize
imbalanced-learn
imgaug
immutabledict
importlib_metadata
importlib_resources
imutils
inflect
iniconfig
intel-cmplr-lib-ur
intel-openmp
ipyevents
ipyfilechooser
ipykernel
ipyleaflet
ipyparallel
ipython
ipython-genutils
ipython-sql
ipytree
ipywidgets
itsdangerous
jax
jeepney
jellyfish
jieba
Jinja2
joblib
jsonpickle
jsonschema
jsonschema-specifications
jupyter-client
jupyter-console
jupyter-server
jupyter_core
jupyterlab_pygments
jupyterlab_widgets
kaggle
kagglehub
keras
keyring
kiwisolver
langcodes
language_data
lazy_loader
libclang
librosa
lightgbm
linkify-it-py
llvmlite
locket
logical-unification
lxml
marisa-trie
Markdown
markdown-it-py
MarkupSafe
matplotlib
matplotlib-inline
matplotlib-venn
mdit-py-plugins
mdurl
miniKanren
missingno
mistune
mizani
mkl
ml-dtypes
mlxtend
more-itertools
moviepy
mpmath
msgpack
multidict
multipledispatch
multitasking
murmurhash
music21
namex
natsort
nbclassic
nbclient
nbconvert
nbformat
nest-asyncio
networkx
nibabel
nltk
notebook
notebook_shim
numba
numexpr
numpy
nvtx
oauth2client
oauthlib
opencv-contrib-python
opencv-python
opencv-python-headless
openpyxl
opt-einsum
optax
optree
orbax-checkpoint
osqp
packaging
pandas
pandas-datareader
pandas-gbq
pandas-stubs
pandocfilters
panel
param
parso
parsy
partd
pathlib
patsy
peewee
pexpect
pickleshare
Pillow
pip-tools
platformdirs
plotly
plotnine
pluggy
polars
pooch
portpicker
prefetch_generator
preshed
prettytable
proglog
progressbar2
prometheus_client
promise
prompt_toolkit
prophet
proto-plus
protobuf
psycopg2-binary
ptyprocess
py-cpuinfo
py4j
pyarrow
pyarrow-hotfix
pyasn1
pyasn1_modules
pycocotools
pycparser
pydantic
pydantic_core
pydata-google-auth
pydot
pydot-ng
pydotplus
PyDrive
PyDrive2
pyerfa
pygame
Pygments
PyJWT
pymc
pymystem3
pynvjitlink-cu12
PyOpenGL
pyOpenSSL
pyparsing
pyperclip
pyproj
pyproject_hooks
pyshp
PySocks
pytensor
pytest
python-box
python-dateutil
python-louvain
python-slugify
python-utils
pytz
pyviz_comms
PyYAML
pyzmq
qdldl
ratelim
referencing
regex
requests
requests-oauthlib
requirements-parser
rich
rpds-py
rsa
safetensors
scikit-image
scikit-learn
scipy
scooby
scs
seaborn
SecretStorage
Send2Trash
sentencepiece
shapely
shellingham
simple_parsing
six
sklearn-pandas
smart-open
sniffio
snowballstemmer
snowflake-connector-python
sortedcontainers
soundfile
soupsieve
soxr
spacy
spacy-legacy
spacy-loggers
Sphinx
sphinxcontrib-applehelp
sphinxcontrib-devhelp
sphinxcontrib-htmlhelp
sphinxcontrib-jsmath
sphinxcontrib-qthelp
sphinxcontrib-serializinghtml
SQLAlchemy
sqlglot
sqlparse
srsly
stanio
statsmodels
StrEnum
sympy
tables
tabulate
tbb
tblib
tenacity
tensorboard
tensorboard-data-server
tensorflow
tensorflow-datasets
tensorflow-hub
tensorflow-io-gcs-filesystem
tensorflow-metadata
tensorflow-probability
tensorstore
termcolor
terminado
text-unidecode
textblob
tf-slim
tf_keras
thinc
threadpoolctl
tifffile
tinycss2
tokenizers
toml
tomli
tomlkit
toolz
torch
torchaudio
torchsummary
torchtext
torchvision
tornado
tqdm
traitlets
traittypes
transformers
triton
tweepy
typeguard
typer
types-pytz
types-setuptools
typing_extensions
tzdata
tzlocal
uc-micro-py
uritemplate
urllib3
vega-datasets
wadllib
wasabi
wcwidth
weasel
webcolors
webencodings
websocket-client
Werkzeug
widgetsnbextension
wordcloud
wrapt
xarray
xarray-einstats
xgboost
xlrd
xyzservices
yarl
yellowbrick
yfinance
zict
zipp
この、妥協版 requirements.txt は僕のローカルPCのWSL環境でもインストールできるので、今後はこれを使っていこうと思います。
フルの会話はこちら: https://chatgpt.com/share/da39c73c-89fa-40cc-81d0-100fa3be222e