如何检查安装了哪个版本的 Keras?

问题和标题说的一样。

我不喜欢打开 Python,我使用 MacOS 或 Ubuntu。

234109 次浏览

Python library authors put the version number in <module>.__version__. You can print it by running this on the command line:

python -c 'import keras; print(keras.__version__)'

If it's Windows terminal, enclose snippet with double-quotes like below

python -c "import keras; print(keras.__version__)"

You can write:

python
import keras
keras.__version__

The simplest way is using pip command:

pip list | grep Keras

Simple command to check keras version:

(py36) C:\WINDOWS\system32>python
Python 3.6.8 |Anaconda custom (64-bit)


>>> import keras
Using TensorFlow backend.
>>> keras.__version__
'2.2.4'

pip show tensorflow

C:\>pip show tensorflow
Name: tensorflow
Version: 2.4.1
Summary: TensorFlow is an open source machine learning framework for
everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
Requires: google-pasta, wheel, absl-py, flatbuffers, numpy, astunparse, opt-
einsum, six, termcolor, typing-extensions, wrapt, grpcio, tensorboard,
protobuf, tensorflow-estimator, gast, h5py, keras-preprocessing
Required-by:

Same way can try for

pip show keras

If it is installed then it will provide the details.

For terminal, run: (Change with python3 for version of Python3)

python -c 'import keras; print(keras.__version__)'

Or if you want to check inside code, include:

import keras
print(keras.__version__)