繁体   English   中英

通过安装了 python 的终端在 macOS 上运行 Keras?

[英]running Keras on macOs through the terminal with python installed?

当我在 macOS 上的终端中键入命令“从 tensorflow 导入 keras”时,我得到

“来自:无法读取 /var/mail/tensorflow”

您不能直接将 Python 代码写入 CLI。 那在某种程度上只接受 shell 命令。

您可以:

  1. 从您的 CLI 启动 Python 解释器并直接使用它,例如
$ python3
Python 3.9.4 (default, Apr  5 2021, 01:50:46)
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from tensorflow import keras
  1. 或将所有代码写入文本文件并将其命名为my_first_script.py之类的名称,例如
#!/usr/bin/env python3

import tensorflow as tf
from tensorflow import keras

# the rest of your code

然后你用 python 运行它,例如

$ python my_first_script.py

在这里查看本教程

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM