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

通过安装python的终端在macOs上运行Keras?,python,Python,当我在macOS上的终端中键入命令“from tensorflow import keras”时,我得到 “from:cannotread/var/mail/tensorflow”您不能直接将Python代码写入CLI。它在某种程度上只接受shell命令 您可以: 从CLI启动Python解释器并直接使用它,例如 或者将所有代码写入文本文件,并将其命名为my_first\u script.py,例如 #/usr/bin/env蟒蛇3 导入tensorflow作为tf 从tensorflow进口k

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


“from:cannotread/var/mail/tensorflow”

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

您可以:

  • 从CLI启动Python解释器并直接使用它,例如
  • 或者将所有代码写入文本文件,并将其命名为
    my_first\u script.py
    ,例如
  • #/usr/bin/env蟒蛇3
    导入tensorflow作为tf
    从tensorflow进口keras
    #代码的其余部分
    
    然后用python运行它,例如

    $python my\u first\u script.py
    
    看看这里

    $ 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