Windows11 python3.11 环境下pybluez的安装

本文介绍了在Windows11环境下,尤其是在Python3.11和pybluez安装时遇到的编译问题,作者分享了如何下载并安装WindowsSDK,以及修改环境变量来解决winsock2.h缺失的错误。
摘要由CSDN通过智能技术生成

Windows11 python3.11 环境下pybluez的安装

参考:
文章1
文章2

按照上文博主的步骤,我的电脑上仍然无法安装。于是记录下我的方法供大家参考。仍然感谢上文博主提供思路!

  1. 下载1

  2. 打开Installer,勾选使用C++的桌面开发,点击安装在这里插入图片描述

  3. 下载windowsSDK在这里插入图片描述

  4. 根据提示安装上述SDK文件

  5. 下载pybluez

  6. 将上述ZIP文件解压。(记录解压后文件夹地址

  7. 在电脑中找到 Microsoft SDKs (一般在C:\Program Files (x86)\Microsoft SDKs\Windows)

  8. 手动修改Microsoft SDKs下文件夹v10.0A为v7.0Acode

  9. 重启电脑

  10. 打开命令管理行,运行 (注意前面的路径)

setx INCLUDE "C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared"
setx LIB "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x64"
  1. cd到记录解压后文件夹地址
  2. 运行以下命令 python setup.py install,等待安装成功

SDK文件和Installer文件都需要下载并安装,在很多教程里只出现了一个。同时,这么做可能会产生很多冗余的文件,如果不介意的话可以参考。

在只有C++桌面开发而没有下载SDK条件下运行文件会出现以下报错信息

PS C:\Users\x> cd C:\Users\x\Downloads\pybluez-master\pybluez-master
PS C:\Users\x\Downloads\pybluez-master\pybluez-master> python setup.py install
running install
C:\Users\x\AppData\Local\Programs\Python\Python311\Lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
C:\Users\x\AppData\Local\Programs\Python\Python311\Lib\site-packages\setuptools\command\easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
running bdist_egg
running egg_info
writing PyBluez.egg-info\PKG-INFO
writing dependency_links to PyBluez.egg-info\dependency_links.txt
writing eager_resources to PyBluez.egg-info\eager_resources.txt
writing requirements to PyBluez.egg-info\requires.txt
writing top-level names to PyBluez.egg-info\top_level.txt
reading manifest file 'PyBluez.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'README'
warning: no files found matching '*.c' under directory 'macos'
warning: no previously-included files matching '*.pyc' found under directory '*'
warning: no previously-included files matching '*.o' found under directory '*'
warning: no previously-included files matching '*.opp' found under directory '*'
adding license file 'COPYING'
writing manifest file 'PyBluez.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
running build_ext
building 'bluetooth._msbt' extension
"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.37.32822\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\x\AppData\Local\Programs\Python\Python311\include -IC:\Users\x\AppData\Local\Programs\Python\Python311\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.37.32822\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" /Tcmsbt\_msbt.c /Fobuild\temp.win-amd64-cpython-311\Release\msbt\_msbt.obj
_msbt.c
msbt\_msbt.c(7): fatal error C1083: 无法打开包括文件: “winsock2.h”: No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.37.32822\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
PS C:\Users\x\Downloads\pybluez-master\pybluez-master>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值