anaconda配置python3.6+opencv4.6+tensorflow2.4环境(最详细)
进入anaconda命令行输入
清华源-i https://pypi.tuna.tsinghua.edu.cn/simple
如果没有配置清华源作为下载核心,可以在末尾加上上面这一句
conda create -n py36 python=3.6 -y
(一个等于号是下最新版本,两个等于号是下3.6.0(不要下3.6.0版本的))
需要的工具
如果你的电脑有20系以上的显卡,请先下载cuda和caa
下面是cuda版本对应tensorflow版本的链接
Build from source on Windows | TensorFlow (google.cn)
下载cuda
CUDA 12.1 Release Notes (nvidia.com)
和cudnn
https://developer.nvidia.cn/zh-cn/cudnn
默认安装即可
接下来我们安装tensorflow
激活环境
conda activate py36
下面的操作都必须在激活py36的情况下
安装tensorflow我们这里安装的是gpu版本
pip install tensorflow-gpu==2.2
cpu版本
pip install tensorflow==2.2
测试tensorflow
输入
python
import tensorflow as tf
tf.constant(1) + tf.constant(1)
如果缺少cudart64_101.dll文件,会提示需要去下载cudart文件
网址如下
https://www.dll-files.com/cudart64_101.dll.html
下载完成放到指定文件夹
安装opencv
opencv对应python3.6的最新版本是4.4.0.46
pip install python-opencv==4.4.0.46
这样安装的一定有补全
jupyter和notebook
如果你接下来要安装jupter可以继续跟着操作
首先更新一下pip
python -m pip install --upgrade pip
安装jupyter
pip install jupyter
pip install notebook
在jupyter中加入kernel
这样就可以在jupter中切换kernel了
python -m ipykernel install --user --py36