Win7,64位,Python2.7.2下的opencv配置

本文详细介绍了如何在Python 2.7环境下安装并配置OpenCV,包括不同版本的安装步骤及常见错误排查方法,并通过一个简单的图像显示示例验证了配置的成功。
部署运行你感兴趣的模型镜像

OpenCV只支持Python的2.6和2.7系列的版本,不支持Python3.x系列的版本。



OpenCV配置:

1、点击下载的opencv-2.4.3.exe,安装到F盘根目录下。

      安装完成后,将F:\opencv243\build\python\2.7下的cv2.pyd拷贝到C:\Python27\Lib\site-packages下面。


输入import  cv2,出现错误:

Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import cv2


Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import cv2
ImportError: DLL load failed: %1 不是有效的 Win32 应用程序。

>>> 



2、点击下载的opencv-3.2.0.exe,安装到F盘根目录下。

    安装完成后,将F:\opencv320\build\python\2.7\x64下的cv2.pyd拷贝到C:\Python27\Lib\site-packages下面。


输入import  cv2,没有错误,说明配置成功。

>>> import cv2
>>> 


简单的测试下

cvtest.py代码如下

import cv2  
  
img = cv2.imread("F:\\lena.jpg")  

cv2.imshow("Image", img)  
cv2.waitKey (0)  
cv2.destroyAllWindows()  

运行后,结果如下:




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

Python3.8

Python3.8

Conda
Python

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

#异步相关依赖 aiofiles==24.1.0 aiohappyeyeballs==2.4.6 aiohttp==3.11.12 aioprometheus==23.12.0 aiosignal==1.3.2 async-timeout==4.0.3 frozenlist==1.5.0 multidict==6.1.0 yarl==1.18.3 #数据处理与可视化 altair==4.2.2 contourpy==1.3.1 cycler==0.12.1 matplotlib==3.10.0 numpy==1.24.4 pandas==1.5.3 pillow==10.4.0 pyparsing==3.2.1 scipy==1.15.3 seaborn==0.13.2 tabulate==0.9.0 #Web 框架与接口 anyio==4.8.0 fastapi==0.109.2 fastapi-mcp==0.3.4 fastjsonschema==2.21.1 h11==0.14.0 httpcore==1.0.7 httptools==0.6.4 httpx==0.27.2 httpx-sse==0.4.0 pydantic==2.7.1 pydantic_core==2.18.4 pydantic-extra-types==2.10.2 pydantic-settings==2.9.1 starlette>=0.36.3,<0.37.0 sse-starlette==1.8.2 uvicorn==0.34.0 websockets==14.2 #LangChain 生态(100% 无冲突,Python 3.10 验证通过) #核心调整:降低 langchain 主版本至 0.2.16,同步匹配子库版本,避免 core 版本交叉冲突 langchain==0.2.16 # 降至 0.2.16(依赖 core≥0.2.36<0.3.0,兼容范围更广) #langchain-community==0.2.1 # 与 langchain==0.2.16 匹配,依赖 core≥0.2.36<0.3.0 langchain-core==0.2.1 # 保持 0.2.x 最高稳定版,同时满足所有子库要求 langchain-experimental==0.0.64 # 降至 0.0.64(0.0.65 依赖更高 core,0.0.64 兼容 core≥0.2.36) langchain-openai==0.2.1 # 降至 0.2.4(依赖 core≥0.2.36<0.3.0,与 core==0.2.43 完美兼容) langchain-text-splitters==0.2.1 # 降至 0.2.3(0.2.4 依赖 core≥0.2.43,此处保持版本统一) langchainhub==0.1.19 # 无 core 版本冲突,保持不变 langsmith==0.1.147 # 无 core 版本冲突,保持不变 #文档处理与解析 beautifulsoup4==4.13.3 docx2txt==0.8 et_xmlfile==2.0.0 favicon==0.7.0 filetype==1.2.0 lxml==5.3.1 markdown-it-py==3.0.0 markdownify==0.14.1 markdownlit==0.0.7 openpyxl==3.1.4 pydub==0.25.1 PyMuPDF==1.23.26 PyMuPDFb==1.23.22 pypdf==5.3.0 python-docx==1.1.2 soupsieve==2.6 unstructured==0.11.8 unstructured-client==0.25.9 #模型与推理相关(适配 Python 3.10) faiss-cpu==1.7.4 huggingface-hub==0.32.1 modelscope==1.18.0 onnxruntime==1.15.1 openai==1.61.1 safetensors==0.5.3 tiktoken==0.8.0 torch==2.7.0 torchvision==0.22.0 xinference-client==1.6.0 xoscar==0.7.2 #数据库与存储 PyMySQL==1.1.1 pyarrow==19.0.0 SQLAlchemy==2.0.38 #工具类与辅助依赖(Python 3.10 兼容) annotated-types==0.7.0 backoff==2.2.1 backports.tarfile==1.2.0 bcrypt==4.3.0 blinker==1.9.0 Brotli==1.1.0 build==1.2.2.post1 CacheControl==0.14.2 cachetools==5.5.1 certifi==2025.1.31 cffi==1.17.1 chardet==5.2.0 charset-normalizer==3.4.1 cleo==2.1.0 click==8.1.8 cloudpickle==3.1.1 colorama==0.4.6 coloredlogs==15.0.1 crashtest==0.4.1 cryptography==44.0.0 dataclasses-json==0.6.7 deepdiff==8.2.0 deprecation==2.1.0 distlib==0.3.9 distro==1.9.0 dnspython==2.7.0 dulwich==0.22.7 ecdsa==0.19.1 elastic-transport==8.17.0 elasticsearch==8.4.3 email_validator==2.2.0 emoji==2.14.1 entrypoints==0.4 exceptiongroup==1.2.2 Faker==36.1.0 ffmpy==0.5.0 filelock==3.17.0 flatbuffers==25.2.10 fonttools==4.56.0 fsspec==2025.5.1 gitdb==4.0.12 GitPython==3.1.44 greenlet==3.1.1 groovy==0.1.2 h2==4.2.0 hpack==4.1.0 htbuilder==0.9.0 humanfriendly==10.0 hyperframe==6.1.0 idna==3.10 importlib_metadata==8.6.1 installer==0.7.0 itsdangerous==2.2.0 jaraco.classes==3.4.0 jaraco.context==6.0.1 jaraco.functools==4.1.0 jieba==0.42.1 Jinja2==3.1.5 jiter==0.8.2 joblib==1.4.2 jsonpatch==1.33 jsonpath-python==1.0.6 jsonpointer==3.0.0 jsonschema==4.23.0 jsonschema-specifications==2024.10.1 keyring==25.6.0 kiwisolver==1.4.8 langdetect==1.0.9 loguru==0.7.3 Markdown==3.7 MarkupSafe==3.0.2 marshmallow==3.26.1 mcp==1.9.0 mdurl==0.1.2 memoization==0.4.0 more-itertools==10.6.0 mpmath==1.3.0 msgpack==1.1.0 mypy-extensions==1.0.0 nest-asyncio==1.6.0 networkx==3.1 nltk==3.8.1 numexpr==2.10.2 nvidia-ml-py==12.575.51 opencv-python==4.10.0.84 orderly-set==5.3.0 orjson==3.10.15 packaging==23.2 passlib==1.7.4 pathlib==1.0.1 pika==1.3.2 pip==25.0 pkginfo==1.12.0 platformdirs==4.3.6 poetry==2.0.1 poetry-core==2.0.1 prometheus_client==0.21.1 propcache==0.2.1 protobuf==4.25.6 psutil==7.0.0 pyahocorasick==2.1.0 pyasn1==0.4.8 pyclipper==1.3.0.post6 pycparser==2.22 pydeck==0.9.1 Pygments==2.19.1 PyJWT==2.8.0 pymdown-extensions==10.14.3 pynvml==12.0.0 pypandoc==1.15 pyproject_hooks==1.2.0 pyreadline3==3.5.4 python-dateutil==2.9.0.post0 python-decouple==3.8 python-dotenv==1.0.1 python-iso639==2025.2.8 python-jose==3.4.0 python-magic==0.4.27 python-multipart==0.0.20 pytz==2025.1 PyYAML==6.0.2 quantile-python==1.1 rank-bm25==0.2.2 RapidFuzz==3.12.1 rapidocr-onnxruntime==1.3.25 referencing==0.36.2 regex==2024.11.6 requests==2.31.0 requests-toolbelt==1.0.0 rich==13.9.4 rpds-py==0.22.0 rsa==4.9.1 ruamel.yaml==0.18.6 ruamel.yaml.clib==0.2.12 ruff==0.11.11 semantic-version==2.10.0 setproctitle==1.3.6 setuptools==75.8.0 shapely==2.0.7 shellingham==1.5.4 simplejson==3.19.3 six==1.17.0 smmap==5.0.2 sniffio==1.3.1 socksio==1.0.0 st-annotated-text==4.0.2 streamlit==1.34.0 streamlit-aggrid==1.0.5 streamlit-antd-components==0.3.1 streamlit-camera-input-live==0.2.0 streamlit-card==1.0.2 streamlit-chatbox==1.1.8 streamlit-embedcode==0.1.2 streamlit-extras==0.4.2 streamlit-faker==0.0.3 streamlit-feedback==0.1.4 streamlit-image-coordinates==0.1.9 streamlit-keyup==0.3.0 streamlit_modal==0.1.0 streamlit-option-menu==0.3.12 streamlit-paste-button==0.1.2 streamlit-toggle-switch==1.0.2 streamlit-vertical-slider==2.5.5 strsimpy==0.2.1 sympy==1.13.3 tblib==3.1.0 tenacity==8.5.0 toml==0.10.2 tomli==2.2.1 tomlkit==0.13.2 toolz==1.0.0 tornado==6.4.2 tqdm==4.67.1 trove-classifiers==2025.1.15.22 typer==0.15.4 types-requests==2.32.0.20241016 typing_extensions==4.12.2 typing-inspect==0.9.0 typing-inspection==0.4.0 tzdata==2025.1 ujson==5.10.0 urllib3==2.3.0 validators==0.34.0 virtualenv==20.29.2 watchdog==6.0.0 watchfiles==1.0.4 win32_setctime==1.2.0 wrapt==1.17.2 zipp==3.21.0 环境 liunx Python 3.10.0 安装依赖 ERROR: Cannot install -r requirements.txt (line 35) and pydantic_core==2.18.4 because these package versions have conflicting dependencies. The conflict is caused by: The user requested pydantic_core==2.18.4 pydantic 2.7.1 depends on pydantic-core==2.18.2 To fix this you could try to: 1. loosen the range of package versions you've specified 2. remove package versions to allow pip to attempt to solve the dependency conflict ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
09-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值