windows anaconda3(python3.6)下安装opencv3//及pip安装opencv无法在pycharm的anconda环境找到扩展包解决方案

本文介绍在Windows环境下使用Anaconda安装特定版本OpenCV的方法。由于Anaconda3(Python3.6)官方未提供对应的OpenCV3包,需要从第三方网站下载.whl文件并进行手动安装。文中详细说明了如何通过修改文件名及使用conda命令来完成安装过程,确保在PyCharm中能够正常导入cv2模块。
部署运行你感兴趣的模型镜像

windows环境下anaconda3(python3.6)没有对应的opencv3的包,因此无法直接安装

解决方式:

进入https://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv下载对应的.whl


修改名字:将cp36m改为none

将.whl拷贝到D:/anaconda3下面

此时如果直接pip install opencv_python-3.4.1+contrib -cp36-none-win_amd64.whl会出现在python环境能import cv2,但在pycharm的anaconda库里找不到cv2的情况

解决方案:不要直接pip install,进入D:\anaconda3\Scripts

将pip.exe和pip-script.py修改为condapip.exe和condapip-script.py(不加conda加别的也行,只为了和系统pip区分开)

condapip install  opencv_python-3.4.1+contrib -cp36-none-win_amd64.whl

之后刷新pycharm interpretor或者重启一下,就可以成功在pycharm anaconda环境下import cv2了。

您可能感兴趣的与本文相关的镜像

Python3.8

Python3.8

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

D:\anconda\envs\ultralytics-main\python.exe D:/Program Files/JetBrains/PyCharm 2025.2.1.1/plugins/python-ce/helpers/packaging_tool.py install albumentations Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple, https://mirrors.tuna.tsinghua.edu.cn/pytorch-wheels/cu128 Collecting albumentations Using cached https://pypi.tuna.tsinghua.edu.cn/packages/8e/64/013409c451a44b61310fb757af4527f3de57fc98a00f40448de28b864290/albumentations-2.0.8-py3-none-any.whl (369 kB) Requirement already satisfied: numpy>=1.24.4 in d:\anconda\envs\ultralytics-main\lib\site-packages (from albumentations) (2.0.1) Collecting scipy>=1.10.0 (from albumentations) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/d1/84/55bc4881973d3f79b479a5a2e2df61c8c9a04fcb986a213ac9c02cfb659b/scipy-1.15.3-cp310-cp310-win_amd64.whl (41.3 MB) Requirement already satisfied: PyYAML in d:\anconda\envs\ultralytics-main\lib\site-packages (from albumentations) (6.0.2) Collecting pydantic>=2.9.2 (from albumentations) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/3e/d3/108f2006987c58e76691d5ae5d200dd3e0f532cb4e5fa3560751c3a1feba/pydantic-2.11.9-py3-none-any.whl (444 kB) Collecting albucore==0.0.24 (from albumentations) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/0a/e2/91f145e1f32428e9e1f21f46a7022ffe63d11f549ee55c3b9265ff5207fc/albucore-0.0.24-py3-none-any.whl (15 kB) Collecting opencv-python-headless>=4.9.0.80 (from albumentations) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/f2/35/0858e9e71b36948eafbc5e835874b63e515179dc3b742cbe3d76bc683439/opencv_python_headless-4.12.0.88-cp37-abi3-win_amd64.whl (38.9 MB) Collecting stringzilla>=3.10.4 (from albucore==0.0.24->albumentations) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/36/e7/80a4151062f83b581630a4972619db0d14cdebaabbf394348187125a4efd/stringzilla-4.0.11.tar.gz (465 kB) Installing build dependencies: started Installing build dependencies: finished with status 'done' Getting requirements to build wheel: started Getting requirements to build wheel: finished with status 'done' Preparing metadata (pyproject.toml): started Preparing metadata (pyproject.toml): finished with status 'done' Collecting simsimd>=5.9.2 (from albucore==0.0.24->albumentations) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/e9/2c/6e66858a6150351e74238357d3b01718f743b405f79a16b9184f07f91748/simsimd-6.5.3-cp310-cp310-win_amd64.whl (94 kB) Collecting annotated-types>=0.6.0 (from pydantic>=2.9.2->albumentations) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/78/b6/6307fbef88d9b5ee7421e68d78a9f162e0da4900bc5f5793f6d3d0e34fb8/annotated_types-0.7.0-py3-none-any.whl (13 kB) Collecting pydantic-core==2.33.2 (from pydantic>=2.9.2->albumentations) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/66/ff/172ba8f12a42d4b552917aa65d1f2328990d3ccfc01d5b7c943ec084299f/pydantic_core-2.33.2-cp310-cp310-win_amd64.whl (2.0 MB) Requirement already satisfied: typing-extensions>=4.12.2 in d:\anconda\envs\ultralytics-main\lib\site-packages (from pydantic>=2.9.2->albumentations) (4.12.2) Collecting typing-inspection>=0.4.0 (from pydantic>=2.9.2->albumentations) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/17/69/cd203477f944c353c31bade965f880aa1061fd6bf05ded0726ca845b6ff7/typing_inspection-0.4.1-py3-none-any.whl (14 kB) Building wheels for collected packages: stringzilla Building wheel for stringzilla (pyproject.toml): started Building wheel for stringzilla (pyproject.toml): finished with status 'error' Failed to build stringzilla error: subprocess-exited-with-error Building wheel for stringzilla (pyproject.toml) did not run successfully. exit code: 1 [10 lines of output] running bdist_wheel running build running build_py creating build\lib.win-amd64-cpython-310\cli copying cli\split.py -> build\lib.win-amd64-cpython-310\cli copying cli\wc.py -> build\lib.win-amd64-cpython-310\cli copying cli\__init__.py -> build\lib.win-amd64-cpython-310\cli running build_ext building 'stringzilla' extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for stringzilla error: failed-wheel-build-for-install Failed to build installable wheels for some pyproject.toml based projects stringzilla Process finished with exit code 1
09-18
当在Python安装`albumentations`库时,`stringzilla`构建轮子失败并提示需要Microsoft Visual C++ 14.0或更高版本,可尝试以下解决办法: ### 安装Visual C++ Build Tools 可以从[Visual Studio Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/)页面下载并安装Visual C++ Build Tools。在安装过程中,确保勾选“使用C++的桌面开发”工作负载,此工作负载含了所需的Visual C++编译器和工具集。安装完成后,重启计算机,再次尝试安装`albumentations`库。 ### 使用Anaconda环境 Anaconda是一个流行的Python发行版,它自带了许多科学计算和数据处理所需的库和工具,并且能避免一些编译问题。可以按照以下步骤操作: 1. 安装Anaconda:从[Anaconda官网](https://www.anaconda.com/products/distribution)下载并安装适合系统的Anaconda版本。 2. 创建并激活新的环境:打开Anaconda Prompt,执行以下命令创建并激活新的环境。 ```bash conda create -n myenv python=3.8 conda activate myenv ``` 3. 安装`albumentations`库:在激活的环境中,使用`conda`或`pip`安装`albumentations`库。 ```bash conda install albumentations # 或者使用pip pip install albumentations ``` ### 使用预编译的二进制 如果上述方法都无法解决问题,可以尝试从[Python Package Index (PyPI)](https://pypi.org/)下载预编译的二进制.whl文件),然后直接安装。 1. 访问[`stringzilla`的PyPI页面](https://pypi.org/project/stringzilla/),下载适合Python版本和操作系统的.whl文件。 2. 打开命令提示符,进入下载文件所在的目录,使用`pip`安装下载的.whl文件。 ```bash pip install stringzilla-<version>-<python_version>-<platform>.whl ``` 3. 安装完`stringzilla`后,再安装`albumentations`库。 ```bash pip install albumentations ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值