2022-10-25 :
推荐使用 Micromamba 替代臃肿的 Anaconda/Miniconda : 【环境搭建】depthai + micromamba
【环境搭建】depthai + conda
一、 下载并安装 Python
推荐使用 miniconda
安装 python
最近发现了一个更小的
micromamba
Micromamba是Mamba包管理器的微小版本。它是一个具有单独命令行界面的纯C ++包。它可用于引导环境(作为Miniconda的替代品)
1. 下载安装包
下载地址:Miniconda3-latest-Windows-x86_64.exe
2. 双击 Miniconda 安装包安装(默认安装)
3. 初始化 conda
打开命令提示符窗口 输入 conda init
初始化 conda
4. 设置国内镜像加速
命令行输入
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
Tips:
添加完后,找到用户文件夹下.condarc 隐藏文件,删除里面的 defaults,这样能快点。
二、 配置环境
可使用
depthai.yml
创建虚拟环境或使用下面的分步骤name: depthai channels: - conda-forge dependencies: - python=3.8 - pip - setuptools - tk - wheel - pip: - depthai-sdk - blobconverter - depthai - numpy - --extra-index-url https://www.piwheels.org/simple - opencv-python==4.5.4.58 ; platform_machine != "aarch64" and platform_machine != "armv6l" and platform_machine != "armv7l" and python_version == "3.10" - opencv-python==4.5.1.48 ; platform_machine != "aarch64" and platform_machine != "armv6l" and platform_machine != "armv7l" and python_version != "3.10" - opencv-contrib-python==4.5.4.58 ; platform_machine != "aarch64" and platform_machine != "armv6l" and platform_machine != "armv7l" and python_version == "3.10" - opencv-contrib-python==4.5.1.48 ; platform_machine != "aarch64" and platform_machine != "armv6l" and platform_machine != "armv7l" and python_version != "3.10" - opencv-python==4.4.0.46 ; platform_machine == "armv6l" or platform_machine == "armv7l" - opencv-contrib-python==4.4.0.46 ; platform_machine == "armv6l" or platform_machine == "armv7l" - pyyaml - requests==2.26.0 - pyrebase4==4.5 - argcomplete==1.12.1 - pyqt5>5,<5.15.6 ; platform_machine != "armv6l" and platform_machine != "armv7l" and platform_machine != "aarch64"
1. 创建 python 虚拟环境
conda create -n depthai python=3.8 -y
### 2. 激活环境
conda activate depthai
3. 设置 pip 国内镜像加速
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
4. 安装 git
git for windows
下载连接 https://mirrors.tuna.tsinghua.edu.cn/github-release/git-for-windows/git/LatestRelease/
在 Linux 上安装
如果你想在 Linux 上用二进制安装程序来安装基本的 Git 工具,可以使用发行版包含的基础软件包管理工具来安装。 以 Fedora 为例,如果你在使用它(或与之紧密相关的基于 RPM 的发行版,如 RHEL 或 CentOS),你可以使用 dnf
:
sudo dnf install git
如果你在基于 Debian 的发行版上,如 Ubuntu,请使用 apt
:
sudo apt install git
要了解更多选择,Git 官方网站上有在各种 Unix 发行版的系统上安装步骤,网址为 https://git-scm.com/download/linux。
5. 安装环境依赖
depthai
depthai
仓库含有版本检测脚本 ,若安装depthai
版本不符会阻止程序运行。推荐为本仓库单独设置一个环境:
conda create -n depthai_demo python=3.8
也可添加
--skipVersionCheck
跳过跳过检测
- 克隆仓库
git clone --depth=1 https://github.com/luxonis/depthai.git
-
安装依赖
conda activate depthai_demo pip install -r requirements.txt -r requirements-optional.txt
-
运行测试
python depthai_demo.py [-gt cv]
depthai-python
- 克隆仓库
git clone --depth=1 https://github.com/luxonis/depthai-python.git
-
安装依赖
运行以下命令后,根据提示按需下载安装
conda activate depthai python examples/install_requirements.py --dry_run
例如:
pip 21.3.1 from <path>/site-packages/pip (python 3.8) python -m pip install -U pip python -m pip install -U --prefer-binary pyyaml requests numpy opencv-python!=4.5.4.58 python -m pip install -U --prefer-binary -U --force-reinstall depthai python <path>/depthai-python/examples/downloader/downloader.py --all --cache_dir <path>/depthai-python/examples/downloader/ --num_attempts 5 -o <path>/depthai-python/examples/models