install tensorflow and jupyter
write contents here
How to
检查一下当前的环境
where pip3
where python3
安装tensorflow
# There is currently no official GPU support for MacOS.
python3 -m pip install tensorflow
# Verify the installation:
python3 -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
安装jupyter
pip3 install notebook
在虚拟环境中安装
# 创建虚拟环境(推荐)
python3 -m venv tf_env
source tf_env/bin/activate
# 安装 TensorFlow 和 Jupyter
pip3 install tensorflow jupyter
# 验证 TensorFlow
python3 -c "import tensorflow as tf; print(tf.__version__)"
# 启动 Jupyter Notebook
jupyter notebook
虚拟环境解释
为什么要使用虚拟环境
- 隔离依赖,避免冲突
- 保护系统 Python
- 便于版本管理和调试
- 与 VSCode 集成更顺畅
- 支持跨平台和可重现性
推荐的文件夹选择
- 项目根目录下(最常用), 位置:将虚拟环境文件夹(如 venv 或 tf_env)放在项目文件夹内部
- 用户主目录下的统一管理文件夹
References
https://jupyter.org/install https://www.tensorflow.org/install/pip