【无标题】

用户尝试以管理员权限运行anaconda命令行来手动安装opencv-python,但遇到了找不到文件的问题,接着在不同目录下执行pythonsetup.pyinstall命令时,接收到CMake的错误提示,指出不推荐直接使用setup.py,并且源目录不存在。最后,用户通过pip3成功安装了opencv-python包。
摘要由CSDN通过智能技术生成

以管理员身份运行anaconda prompt


(base) C:\WINDOWS\system32>cd /d D:

(base) D:\>cd ProgramData\anaconda3\Lib\site-packages

(base) D:\ProgramData\anaconda3\Lib\site-packages>python.exe setup.py install
python.exe: can't open file 'D:\\ProgramData\\anaconda3\\Lib\\site-packages\\setup.py': [Errno 2] No such file or directory

(base) D:\ProgramData\anaconda3\Lib\site-packages>cd opencv-python-4.8.0.74

(base) D:\ProgramData\anaconda3\Lib\site-packages\opencv-python-4.8.0.74>python.exe setup.py install
D:\ProgramData\anaconda3\Lib\site-packages\setuptools\_distutils\cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` directly.
        Instead, use pypa/build, pypa/installer, pypa/build or
        other standards-based tools.

        See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
        ********************************************************************************

!!
  self.initialize_options()
CMake Error: The current CMakeCache.txt directory D:/ProgramData/anaconda3/Lib/site-packages/opencv-python-4.8.0.74/_skbuild/win-amd64-3.11/cmake-build/CMakeCache.txt is different than the directory d:/医学院/opencv-python-4.8.0.74/_skbuild/win-amd64-3.11/cmake-build where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt
CMake is re-running because D:/医学院/opencv-python-4.8.0.74/_skbuild/win-amd64-3.11/cmake-build/CMakeFiles/generate.stamp dependency file is missing.
CMake Error: The current CMakeCache.txt directory D:/ProgramData/anaconda3/Lib/site-packages/opencv-python-4.8.0.74/_skbuild/win-amd64-3.11/cmake-build/CMakeCache.txt is different than the directory d:/医学院/opencv-python-4.8.0.74/_skbuild/win-amd64-3.11/cmake-build where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt
CMake Error: The source directory "D:/医学院/opencv-python-4.8.0.74/opencv" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
CMake Configure step failed.  Build files cannot be regenerated correctly.
Traceback (most recent call last):
  File "C:\Users\lllggg\AppData\Roaming\Python\Python311\site-packages\skbuild\setuptools_wrap.py", line 674, in setup
    cmkr.make(make_args, install_target=cmake_install_target, env=env)
  File "C:\Users\lllggg\AppData\Roaming\Python\Python311\site-packages\skbuild\cmaker.py", line 697, in make
    self.make_impl(clargs=clargs, config=config, source_dir=source_dir, install_target=install_target, env=env)
  File "C:\Users\lllggg\AppData\Roaming\Python\Python311\site-packages\skbuild\cmaker.py", line 742, in make_impl
    raise SKBuildError(msg)

An error occurred while building with CMake.
  Command:
    'C:\Users\lllggg\AppData\Roaming\Python\Python311\site-packages\cmake\data\bin/cmake.exe' --build . --target install --config Release --
  Install target:
    install
  Source directory:
    D:\ProgramData\anaconda3\Lib\site-packages\opencv-python-4.8.0.74
  Working directory:
    D:\ProgramData\anaconda3\Lib\site-packages\opencv-python-4.8.0.74\_skbuild\win-amd64-3.11\cmake-build
Please check the install target is valid and see CMake's output for more information.


(base) D:\ProgramData\anaconda3\Lib\site-packages\opencv-python-4.8.0.74>

(base) D:\ProgramData\anaconda3\Lib\site-packages\opencv-python-4.8.0.74>python
Python 3.11.3 | packaged by Anaconda, Inc. | (main, Apr 19 2023, 23:46:34) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit
Use exit() or Ctrl-Z plus Return to exit
>>> ^Z


(base) D:\ProgramData\anaconda3\Lib\site-packages\opencv-python-4.8.0.74>pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple cmake
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: cmake in c:\users\lllggg\appdata\roaming\python\python311\site-packages (3.26.4)

(base) D:\ProgramData\anaconda3\Lib\site-packages\opencv-python-4.8.0.74>pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting opencv-python
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a6/08/583e1d8d589e80a702815f58daa317bd469a32c7dc339394e2a0dc14318b/opencv_python-4.8.0.74-cp37-abi3-win_amd64.whl (38.1 MB)
     ---------------------------------------- 38.1/38.1 MB 18.7 MB/s eta 0:00:00
Requirement already satisfied: numpy>=1.21.2 in d:\programdata\anaconda3\lib\site-packages (from opencv-python) (1.24.3)
Installing collected packages: opencv-python
Successfully installed opencv-python-4.8.0.74

(base) D:\ProgramData\anaconda3\Lib\site-packages\opencv-python-4.8.0.74>
(base) D:\ProgramData\anaconda3\Lib\site-packages\opencv-python-4.8.0.74>

 千辛万苦cd进入anaconda装包的目录底下,那边准备好了俩tar.gz的解压包,绕了一圈,还是直接拍一句话就行:

(base) D:\ProgramData\anaconda3\Lib\site-packages\opencv-python-4.8.0.74>pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python
 

pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python

参考:opencv-python安装报错&解决 - 知乎

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值