Windows 11 に Miniforge を入れた。
https://conda-forge.org/download/
から Windows(x86_64) を選ぶ
インストーラーのデフォルトでは下記に入るようだ。
C:\ProgramData\miniforge3
とくに変更はしなかった。これでインストールできた。
スタートメニューから Miniforge prompt を起動してみる。
(base) C:\Users\myusername>
(base) が入っている。
(base) C:\Users\myusername>conda config --set auto_activate_base false
一度閉じて再度開けてみる。
(base) C:\Users\myusername>
(base) が残っている。まあいいや。
(base) C:\Users\myusername>conda create --name=py312 python=3.12 (中略) Proceed ([y]/n)? y (中略) # # To activate this environment, use # # $ conda activate py312 # # To deactivate an active environment, use # # $ conda deactivate
これでよし。以下プロンプトは単に C:> で表す。
(base) C:>conda create activate py312
次に、役に立つライブラリをインストールする。 @_Moony 氏のMiniforgeによるPythonの開発環境構築(画像処理やディープラーニングの画像認識で使用)(qiita.com)にならった。
(py312) C:>conda install numpy scipy sympy matplotlib scikit-learn pandas jupyter notebook ipykernel jupyterlab graphviz pydot
問題なくインストールできたようだ。なお、ライブラリの内容は次のとおりである。
その後、conda install hogehoge で次のものをインストールした。
conda から tensorflow はインストールできるだろうか。
(py312) C:>conda install tensorflow
(中略)
tensorflow is not installable because there are no viable options
(後略)
pip (pip3) ではどうだろうか。
(py312) C:>pip3 install tensorflow
(中略)
Attempting uninstall: numpy
Found existing installation: numpy 2.2.2
Uninstalling numpy-2.2.2:
Successfully uninstalled numpy-2.2.2
Successfully installed absl-py-2.1.0 astunparse-1.6.3 flatbuffers-25.2.10 gast-0.6.0 google-pasta-0.2.0 grpcio-1.71.0
h5py-3.13.0 keras-3.9.0 libclang-18.1.1 markdown-3.7 markdown-it-py-3.0.0 mdurl-0.1.2 ml-dtypes-0.5.1 namex-0.0.8
numpy-2.1.3 opt-einsum-3.4.0 optree-0.14.1 protobuf-5.29.3 rich-13.9.4 tensorboard-2.19.0 tensorboard-data-server-0.7.2
tensorflow-2.19.0 termcolor-2.5.0 werkzeug-3.1.3 wrapt-1.17.2
インストールできたようだ。実際にどうなっているのだろうか。
(py312) C:>python
Python 3.12.9 | packaged by Anaconda, Inc. | (main, Feb 6 2025, 18:49:16) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow 2025-03-14 21:45:30.807656: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`. 2025-03-14 21:45:31.807080: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`. >>> tensorflow.__version__ '2.19.0'
大丈夫だ(2025-03-14)。
conda から mecab-python3 はインストールできるだろうか。
C:> conda install -c conda-forge mecab-python3
では、インストールできない。つまり、conda-forge チャンネルにはない。 ちなみに、上記はコマンドラインから行なったが、Jupyter lab を立ち上げたあとで、 !conda install -c conda-forge mecab-python3 としてみたが、やはりインストールできなかった。
Qiita では、mzh というチャンネルにあるようだ。どうだろうか。C:> conda install -c mzh mecab-python3 Channels: - mzh - defaults - conda-forge Platform: win-64 Collecting package metadata (repodata.json): done Solving environment: \ warning libmamba Added empty dependency for problem type SOLVER_RULE_UPDATE failed LibMambaUnsatisfiableError: Encountered problems while solving: - package mecab-python3-1.0.3-py35_0 requires python >=3.5,<3.6.0a0, but none of the providers can be installed Could not solve for environment specs The following packages are incompatible ├─ mecab-python3 is installable with the potential options │ ├─ mecab-python3 1.0.3 would require │ │ └─ python >=3.5,<3.6.0a0 , which can be installed; │ ├─ mecab-python3 1.0.3 would require │ │ └─ python >=3.6,<3.7.0a0 , which can be installed; │ ├─ mecab-python3 1.0.3 would require │ │ └─ python >=3.7,<3.8.0a0 , which can be installed; │ ├─ mecab-python3 1.0.3 would require │ │ └─ python 3.8.* , which can be installed; │ └─ mecab-python3 1.0.3 would require │ └─ python 3.9.* , which can be installed; └─ pin-1 is not installable because it requires └─ python 3.12.* , which conflicts with any installable versions previously reported.
どうも Python 3.12 は新しすぎるようだ。
pip はどうだろうか。
(py312) C:> pip install mecab-python3 Collecting mecab-python3 Downloading mecab_python3-1.0.10-cp312-cp312-win_amd64.whl.metadata (6.3 kB) Downloading mecab_python3-1.0.10-cp312-cp312-win_amd64.whl (503 kB) Installing collected packages: mecab-python3 Successfully installed mecab-python3-1.0.10
大丈夫だった。
pytorch も入れた。
(py312) C:> conda install pytorch
Windows Subsystem on Linux の Ubuntu 22.04 LTS に Miniforge を入れた。
https://conda-forge.org/download/
からx86_64 (amd64) を選ぶ。
$ sh ./Miniforge3-Linux-x86_64.sh (中略) To activate this environment, use: micromamba activate /home/myusername/miniforge3 Or to execute a single command in this environment, use: micromamba run -p /home/myusername/miniforge3 mycommand installation finished. Do you wish to update your shell profile to automatically initialize conda? This will activate conda on startup and change the command prompt when activated. If you'd prefer that conda's base environment not be activated on startup, run the following command when conda is activated: conda config --set auto_activate_base false You can undo this by running `conda init --reverse $SHELL`? [yes|no] [no] >>> no You have chosen to not have conda modify your shell scripts at all. To activate conda's base environment in your current shell session: eval "$(/home/myusername/miniforge3/bin/conda shell.YOUR_SHELL_NAME hook)" To install conda's shell functions for easier access, first activate, then: conda init Thank you for installing Miniforge3!
動くだろうか。
$ conda conda: コマンドが見つかりません
https://github.com/conda-forge/miniforge を見るとこう書かれている。
Note that one can also just add the C:\Users\myusername\miniforge3\condabin folder to the path environment variable manually so conda and mamba may be used more conveniently from any command prompt with limited chance of software conflicts.
The same situation arises on Unix if you use the non-interactive install. Initialization can be done by calling conda with its full path, with something like
~/miniforge3/bin/conda init
ということでやってみた。
$ ~/miniforge3/bin/conda init no change /home/myusername/miniforge3/condabin/conda (中略) no change /home/myusername/miniforge3/etc/profile.d/conda.csh modified /home/myusername/.bashrc ==> For changes to take effect, close and re-open your current shell. <==
いったんこのウィンドウを閉じ、再度シェルを立ち上げると、プロンプトに (base) がある。
(base) $
ということは、 デフォルトの動作として、シェルの初期化時にベース環境を自動的に有効化しているということだ。 Conda によって管理されていない Python のインストールを併用しているので、この動作は避けたい。 ということで、下記の回避策を実行した。
(base) $ conda config --set auto_activate_base false
いったんこのウィンドウを閉じ、再度シェルを立ち上げると、プロンプトから (base) が消えている。
$
$ conda create --name=py312 python=3.12 (中略) Proceed ([y]/n)? y (中略) # # To activate this environment, use # # $ conda activate py312 # # To deactivate an active environment, use # # $ conda deactivate
$ (py312)$ conda install numpy scipy sympy matplotlib scikit-learn pandas jupyter notebook ipykernel jupyterlab graphviz pydot
うまくインストールできたようだ。
$ (py312)$ conda tensorflow (中略) ## Package Plan ## environment location: /home/username/miniforge3/envs/py312 added / updated specs: - tensorflow The following packages will be downloaded: (中略) Proceed ([y]/n)? y (中略) Preparing transaction: done Verifying transaction: done Executing transaction: - By downloading and using the cuDNN conda packages, you accept the terms and conditions of the NVIDIA cuDNN EULA - https://docs.nvidia.com/deeplearning/cudnn/sla/index.html done
Windows では tensorflow の conda install はできなかったが、WSL2 ではできた。
最後に表示された NVIDIA cuDNN EULA の用語と条件については既に許諾している。
まりんきょ学問所 > Python の開墾 > Miniforge