win10环境下python安装cython-bbox模块出错的解决

2023-10-20 11:10

本文主要是介绍win10环境下python安装cython-bbox模块出错的解决,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

一、现象描述

在win10  python3.10 环境下安装cython-bbox,用pip install cython-bbox出现无法安装的问题,报错如下图:

报错文字:

Processing c:\users\administrator\cython_bbox-0.1.3.tar.gz
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: cython-bbox
  Building wheel for cython-bbox (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [11 lines of output]
      running bdist_wheel
      running build
      running build_ext
      building 'cython_bbox' extension
      creating build
      creating build\temp.win-amd64-cpython-310
      creating build\temp.win-amd64-cpython-310\Release
      creating build\temp.win-amd64-cpython-310\Release\src
      "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site
-packages\numpy\core\include -IC:\Users\Administrator\AppData\Local\Programs\Python\Python310\include -IC:\Users\Administrator\AppData\Local\Programs\Python\Python310\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019
\BuildTools\VC\Tools\MSVC\14.29.30133\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\
include\10.0.19041.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt" /Tcsrc/cython_bbox.c /Fobuild\temp.win-amd64-cpython-310\Rele
ase\src/cython_bbox.obj -Wno-cpp
      cl: 命令行 error D8021 :无效的数值参数“/Wno-cpp”
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for cython-bbox
  Running setup.py clean for cython-bbox
Failed to build cython-bbox
ERROR: Could not build wheels for cython-bbox, which is required to install pyproject.toml-based projects

 错误主要出现在: ERROR: Failed building wheel for cython-bbox,翻译出来就是构建cython-bbox失败。

分析原因:语句提示:     Preparing metadata (setup.py) ... done 

                                        cl: 命令行 error D8021 :无效的数值参数“/Wno-cpp”

打开 setup.py文件,内容如下:

ext_modules = [Extension(name='cython_bbox',sources=['src/cython_bbox.pyx'],extra_compile_args = [-Wno-cpp],include_dirs=[numpy_include])

经过查询资料,将extra_compile_args = [-Wno-cpp] 语句改换为 extra_compile_args = {'gcc': ['/Qstd=c99']}。如下:

ext_modules = [Extension(name='cython_bbox',sources=['src/cython_bbox.pyx'],extra_compile_args = {'gcc': ['/Qstd=c99']},include_dirs=[numpy_include])

保存退出,重新安装,仍然不行。于是:

二、安装步骤

1.下载cython-bbox包:

pip download -i https://pypi.tuna.tsinghua.edu.cn/simple cython_bbox 

# 下载cython-bbox模块
pip download -i https://pypi.tuna.tsinghua.edu.cn/simple cython_bbox

2.解压后找到setup.py,更改前面的语句。

extra_compile_args = [-Wno-cpp],    改为:extra_compile_args = {'gcc': ['/Qstd=c99']},

3.下载dev-cpp并安装

下载地址:https://download.csdn.net/download/qq_58168857/88152647?spm=1001.2014.3001.5501

4.在cmd或powershell中,进入cython-bbox文件夹

cd C:\Users\Administrator\cython_bbox-0.1.3

在cython_ccox-0.13目录下,

5. 输入以下命令进行安装

python setup.py build_ext install

一般情况下,都能正确安装 了。安装结果如下:

PS C:\Users\Administrator\cython_bbox-0.1.3> python setup.py build_ext install
Compiling src/cython_bbox.pyx because it changed.
[1/1] Cythonizing src/cython_bbox.pyx
C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\Cython\Compiler\Main.py:381: FutureW
arning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: C:\Users\Administrator\cython_bbox-0.1.3\src\cython_bbox.pyxtree = Parsing.p_module(s, pxd, full_module_name)
running build_ext
building 'cython_bbox' extension
creating build
creating build\temp.win-amd64-cpython-310
creating build\temp.win-amd64-cpython-310\Release
creating build\temp.win-amd64-cpython-310\Release\src
"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packa
ges\numpy\core\include -IC:\Users\Administrator\AppData\Local\Programs\Python\Python310\include -IC:\Users\Administrator\AppData\Local\Programs\Python\Python310\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Build
Tools\VC\Tools\MSVC\14.29.30133\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\includ
e\10.0.19041.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt" /Tcsrc/cython_bbox.c /Fobuild\temp.win-amd64-cpython-310\Release\sr
c/cython_bbox.obj gcc
cl: 命令行 warning D9024 :无法识别的源文件类型“gcc”,假定为对象文件
cl: 命令行 warning D9027 :源文件“gcc”被忽略
cython_bbox.c
C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(14) : Warning Msg: Using deprecated NumPy API, disable it with #define NPY_NO_DEPRECATED_API NPY_1
_7_API_VERSION
src/cython_bbox.c(4280): warning C4244: “=”: 从“npy_intp”转换到“unsigned int”,可能丢失数据
src/cython_bbox.c(4290): warning C4244: “=”: 从“npy_intp”转换到“unsigned int”,可能丢失数据
creating C:\Users\Administrator\cython_bbox-0.1.3\build\lib.win-amd64-cpython-310
"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\link.exe" /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\Users\Administrator\AppData\L
ocal\Programs\Python\Python310\libs /LIBPATH:C:\Users\Administrator\AppData\Local\Programs\Python\Python310 /LIBPATH:C:\Users\Administrator\AppData\Local\Programs\Python\Python310\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Mi
crosoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64" /EXPOR
T:PyInit_cython_bbox build\temp.win-amd64-cpython-310\Release\src/cython_bbox.obj /OUT:build\lib.win-amd64-cpython-310\cython_bbox.cp310-win_amd64.pyd /IMPLIB:build\temp.win-amd64-cpython-310\Release\src\cython_bbox.cp310-win_amd
64.lib正在创建库 build\temp.win-amd64-cpython-310\Release\src\cython_bbox.cp310-win_amd64.lib 和对象 build\temp.win-amd64-cpython-310\Release\src\cython_bbox.cp310-win_amd64.exp
正在生成代码
已完成代码的生成
running install
C:\Users\Administrator\AppData\Local\Programs\Python\Python310\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 or otherstandards-based tools.See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.********************************************************************************!!self.initialize_options()
C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\cmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!********************************************************************************Please avoid running ``setup.py`` and ``easy_install``.Instead, use pypa/build, pypa/installer or otherstandards-based tools.See https://github.com/pypa/setuptools/issues/917 for details.********************************************************************************!!self.initialize_options()
running bdist_egg
running egg_info
writing cython_bbox.egg-info\PKG-INFO
writing dependency_links to cython_bbox.egg-info\dependency_links.txt
writing top-level names to cython_bbox.egg-info\top_level.txt
reading manifest file 'cython_bbox.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'cython_bbox.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
creating build\bdist.win-amd64
creating build\bdist.win-amd64\egg
copying build\lib.win-amd64-cpython-310\cython_bbox.cp310-win_amd64.pyd -> build\bdist.win-amd64\egg
creating stub loader for cython_bbox.cp310-win_amd64.pyd
byte-compiling build\bdist.win-amd64\egg\cython_bbox.py to cython_bbox.cpython-310.pyc
creating build\bdist.win-amd64\egg\EGG-INFO
copying cython_bbox.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO
copying cython_bbox.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying cython_bbox.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying cython_bbox.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO
writing build\bdist.win-amd64\egg\EGG-INFO\native_libs.txt
zip_safe flag not set; analyzing archive contents...
__pycache__.cython_bbox.cpython-310: module references __file__
creating dist
creating 'dist\cython_bbox-0.1.3-py3.10-win-amd64.egg' and adding 'build\bdist.win-amd64\egg' to it
removing 'build\bdist.win-amd64\egg' (and everything under it)
Processing cython_bbox-0.1.3-py3.10-win-amd64.egg
creating c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages\cython_bbox-0.1.3-py3.10-win-amd64.egg
Extracting cython_bbox-0.1.3-py3.10-win-amd64.egg to c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages
Adding cython-bbox 0.1.3 to easy-install.pth fileInstalled c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages\cython_bbox-0.1.3-py3.10-win-amd64.egg
Processing dependencies for cython-bbox==0.1.3
Finished processing dependencies for cython-bbox==0.1.3

6.检模块包安装情况

pip list

三、注意事项

1.python 版本最好高于3.8,到www.python.org下载并安装原生python包。

2. 安装cyphon-bbox前,记得先安装cython,(pip install cython),这个是安装cython-bbox的另一个前置条件。

3.安装 cython-bbox时,注意所选默认python的版本(安装目录)。

这篇关于win10环境下python安装cython-bbox模块出错的解决的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/246722

相关文章

Python FastAPI+Celery+RabbitMQ实现分布式图片水印处理系统

《PythonFastAPI+Celery+RabbitMQ实现分布式图片水印处理系统》这篇文章主要为大家详细介绍了PythonFastAPI如何结合Celery以及RabbitMQ实现简单的分布式... 实现思路FastAPI 服务器Celery 任务队列RabbitMQ 作为消息代理定时任务处理完整

Python Websockets库的使用指南

《PythonWebsockets库的使用指南》pythonwebsockets库是一个用于创建WebSocket服务器和客户端的Python库,它提供了一种简单的方式来实现实时通信,支持异步和同步... 目录一、WebSocket 简介二、python 的 websockets 库安装三、完整代码示例1.

揭秘Python Socket网络编程的7种硬核用法

《揭秘PythonSocket网络编程的7种硬核用法》Socket不仅能做聊天室,还能干一大堆硬核操作,这篇文章就带大家看看Python网络编程的7种超实用玩法,感兴趣的小伙伴可以跟随小编一起... 目录1.端口扫描器:探测开放端口2.简易 HTTP 服务器:10 秒搭个网页3.局域网游戏:多人联机对战4.

使用Python实现快速搭建本地HTTP服务器

《使用Python实现快速搭建本地HTTP服务器》:本文主要介绍如何使用Python快速搭建本地HTTP服务器,轻松实现一键HTTP文件共享,同时结合二维码技术,让访问更简单,感兴趣的小伙伴可以了... 目录1. 概述2. 快速搭建 HTTP 文件共享服务2.1 核心思路2.2 代码实现2.3 代码解读3.

Linux系统中卸载与安装JDK的详细教程

《Linux系统中卸载与安装JDK的详细教程》本文详细介绍了如何在Linux系统中通过Xshell和Xftp工具连接与传输文件,然后进行JDK的安装与卸载,安装步骤包括连接Linux、传输JDK安装包... 目录1、卸载1.1 linux删除自带的JDK1.2 Linux上卸载自己安装的JDK2、安装2.1

Python使用自带的base64库进行base64编码和解码

《Python使用自带的base64库进行base64编码和解码》在Python中,处理数据的编码和解码是数据传输和存储中非常普遍的需求,其中,Base64是一种常用的编码方案,本文我将详细介绍如何使... 目录引言使用python的base64库进行编码和解码编码函数解码函数Base64编码的应用场景注意

Python基于wxPython和FFmpeg开发一个视频标签工具

《Python基于wxPython和FFmpeg开发一个视频标签工具》在当今数字媒体时代,视频内容的管理和标记变得越来越重要,无论是研究人员需要对实验视频进行时间点标记,还是个人用户希望对家庭视频进行... 目录引言1. 应用概述2. 技术栈分析2.1 核心库和模块2.2 wxpython作为GUI选择的优

Linux卸载自带jdk并安装新jdk版本的图文教程

《Linux卸载自带jdk并安装新jdk版本的图文教程》在Linux系统中,有时需要卸载预装的OpenJDK并安装特定版本的JDK,例如JDK1.8,所以本文给大家详细介绍了Linux卸载自带jdk并... 目录Ⅰ、卸载自带jdkⅡ、安装新版jdkⅠ、卸载自带jdk1、输入命令查看旧jdkrpm -qa

Python如何使用__slots__实现节省内存和性能优化

《Python如何使用__slots__实现节省内存和性能优化》你有想过,一个小小的__slots__能让你的Python类内存消耗直接减半吗,没错,今天咱们要聊的就是这个让人眼前一亮的技巧,感兴趣的... 目录背景:内存吃得满满的类__slots__:你的内存管理小助手举个大概的例子:看看效果如何?1.

Python+PyQt5实现多屏幕协同播放功能

《Python+PyQt5实现多屏幕协同播放功能》在现代会议展示、数字广告、展览展示等场景中,多屏幕协同播放已成为刚需,下面我们就来看看如何利用Python和PyQt5开发一套功能强大的跨屏播控系统吧... 目录一、项目概述:突破传统播放限制二、核心技术解析2.1 多屏管理机制2.2 播放引擎设计2.3 专