简体   繁体   中英

running Keras on macOs through the terminal with python installed?

When I type the command, 'from tensorflow import keras' into the terminal on macOS, I get

"from: can't read /var/mail/tensorflow"

You can't just write Python code into the CLI directly. That only accepts shell commands to some extent.

You can either:

  1. fire up a Python interpreter from your CLI and use that directly, eg
$ 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. or write all of your code into a text file and name it something like my_first_script.py , eg
#!/usr/bin/env python3

import tensorflow as tf
from tensorflow import keras

# the rest of your code

Then you run that with python, eg

$ python my_first_script.py

Check out this tutorial here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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