通过pip安装毕色和导入的麻烦

发布于 2025-01-25 05:29:57 字数 3496 浏览 2 评论 0原文

我必须使用毕达斯特(Pybluez)做某事,我的代码上有错误,所以我告诉自己要以“代码示例”毕毕尔布鲁斯(Pybluez)中的内容开始,但是我也有示例中的错误。

这是一个例子:

#!/usr/bin/env python3
import bluetooth

server_sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
server_sock.bind(("", bluetooth.PORT_ANY))
server_sock.listen(1)

port = server_sock.getsockname()[1]

uuid = "94f39d29-7d6d-437d-973b-fba39e49d4ee"

bluetooth.advertise_service(server_sock, "SampleServer", service_id=uuid,
                            service_classes=[uuid, bluetooth.SERIAL_PORT_CLASS],
                            profiles=[bluetooth.SERIAL_PORT_PROFILE],
                            # protocols=[bluetooth.OBEX_UUID]
                            )

print("Waiting for connection on RFCOMM channel", port)

client_sock, client_info = server_sock.accept()
print("Accepted connection from", client_info)

try:
    while True:
        data = client_sock.recv(1024)
        if not data:
            break
        print("Received", data)
except OSError:
    pass

print("Disconnected.")

client_sock.close()
server_sock.close()
print("All done.")

所以我试图通过PIP重新安装毕色,我卸载了它并运行了命令

pip install git+https://github.com/pybluez/pybluez#egg=Pybluez

我也有错误...

PS C:\Users\AWWP2UY> pip install git+https://github.com/pybluez/pybluez#egg=Pybluez
Collecting Pybluez
  Cloning https://github.com/pybluez/pybluez to c:\users\awwp2uy\appdata\local\temp\pip-install-vnq86zsj\pybluez_60d3f467b9d64a8692e045a4ad16478a
  Running command git clone --filter=blob:none --quiet https://github.com/pybluez/pybluez 'C:\Users\AWWP2UY\AppData\Local\Temp\pip-install-vnq86zsj\pybluez_60d3f467b9d64a8692e045a4ad16478a'
  Resolved https://github.com/pybluez/pybluez to commit 07ebef044195331a48bbb90a3acb911922048ba0
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for Pybluez, since package 'wheel' is not installed.
Installing collected packages: Pybluez
  Running setup.py install for Pybluez ... error
  error: subprocess-exited-with-error
  
  × Running setup.py install for Pybluez did not run successfully.
  │ exit code: 1
  ╰─> [16 lines of output]
      running install
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-3.9
      creating build\lib.win-amd64-3.9\bluetooth
      copying bluetooth\ble.py -> build\lib.win-amd64-3.9\bluetooth
      copying bluetooth\bluez.py -> build\lib.win-amd64-3.9\bluetooth
      copying bluetooth\btcommon.py -> build\lib.win-amd64-3.9\bluetooth
      copying bluetooth\macos.py -> build\lib.win-amd64-3.9\bluetooth
      copying bluetooth\msbt.py -> build\lib.win-amd64-3.9\bluetooth
      copying bluetooth\widcomm.py -> build\lib.win-amd64-3.9\bluetooth
      copying bluetooth\__init__.py -> build\lib.win-amd64-3.9\bluetooth
      running build_ext
      building 'bluetooth._msbt' 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: legacy-install-failure

× Encountered error while trying to install package.
╰─> Pybluez

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the fail

我很困惑,因为这是导入错误,在大多数情况下,您只需要重新安装模块...

I'm have to do something using a Pybluez, I had errors on my code, so I told myself to start with "code example" what is in Pybluez, but I have errors in example too.

This is the example:

#!/usr/bin/env python3
import bluetooth

server_sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
server_sock.bind(("", bluetooth.PORT_ANY))
server_sock.listen(1)

port = server_sock.getsockname()[1]

uuid = "94f39d29-7d6d-437d-973b-fba39e49d4ee"

bluetooth.advertise_service(server_sock, "SampleServer", service_id=uuid,
                            service_classes=[uuid, bluetooth.SERIAL_PORT_CLASS],
                            profiles=[bluetooth.SERIAL_PORT_PROFILE],
                            # protocols=[bluetooth.OBEX_UUID]
                            )

print("Waiting for connection on RFCOMM channel", port)

client_sock, client_info = server_sock.accept()
print("Accepted connection from", client_info)

try:
    while True:
        data = client_sock.recv(1024)
        if not data:
            break
        print("Received", data)
except OSError:
    pass

print("Disconnected.")

client_sock.close()
server_sock.close()
print("All done.")

So I tryed to reinstall Pybluez via pip, I uninstalled it and runned command

pip install git+https://github.com/pybluez/pybluez#egg=Pybluez

I've got error too...

PS C:\Users\AWWP2UY> pip install git+https://github.com/pybluez/pybluez#egg=Pybluez
Collecting Pybluez
  Cloning https://github.com/pybluez/pybluez to c:\users\awwp2uy\appdata\local\temp\pip-install-vnq86zsj\pybluez_60d3f467b9d64a8692e045a4ad16478a
  Running command git clone --filter=blob:none --quiet https://github.com/pybluez/pybluez 'C:\Users\AWWP2UY\AppData\Local\Temp\pip-install-vnq86zsj\pybluez_60d3f467b9d64a8692e045a4ad16478a'
  Resolved https://github.com/pybluez/pybluez to commit 07ebef044195331a48bbb90a3acb911922048ba0
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for Pybluez, since package 'wheel' is not installed.
Installing collected packages: Pybluez
  Running setup.py install for Pybluez ... error
  error: subprocess-exited-with-error
  
  × Running setup.py install for Pybluez did not run successfully.
  │ exit code: 1
  ╰─> [16 lines of output]
      running install
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-3.9
      creating build\lib.win-amd64-3.9\bluetooth
      copying bluetooth\ble.py -> build\lib.win-amd64-3.9\bluetooth
      copying bluetooth\bluez.py -> build\lib.win-amd64-3.9\bluetooth
      copying bluetooth\btcommon.py -> build\lib.win-amd64-3.9\bluetooth
      copying bluetooth\macos.py -> build\lib.win-amd64-3.9\bluetooth
      copying bluetooth\msbt.py -> build\lib.win-amd64-3.9\bluetooth
      copying bluetooth\widcomm.py -> build\lib.win-amd64-3.9\bluetooth
      copying bluetooth\__init__.py -> build\lib.win-amd64-3.9\bluetooth
      running build_ext
      building 'bluetooth._msbt' 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: legacy-install-failure

× Encountered error while trying to install package.
╰─> Pybluez

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the fail

I'm so confused because it's import error, in most cases you have to just reinstall module...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

痴情 2025-02-01 05:29:57

毕色库图书馆的问题是问题,当我将每个“蓝牙”更改为“插座”时,它可以正常工作。

It was problem with Pybluez Library, when I changed every "bluetooth" to a "socket", it work as it have to work.

寄意 2025-02-01 05:29:57

为什么不安装轮套?
在我的Windows 10 CMD中,它起作用了。

D:\Users\aaa\Documents\temp>pip3 install wheel
Defaulting to user installation because normal site-packages is not writeable
Collecting wheel
  Using cached wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel
Successfully installed wheel-0.37.1
WARNING: You are using pip version 21.3.1; however, version 22.0.4 is available.
You should consider upgrading via the 'c:\program files\python39\python.exe -m pip install --upgrade pip' command.

D:\Users\aaa\Documents\temp>pip install git+https://github.com/pybluez/pybluez#egg=Pybluez
Defaulting to user installation because normal site-packages is not writeable
Collecting Pybluez
  Cloning https://github.com/pybluez/pybluez to c:\users\aaa\appdata\local\temp\pip-install-0c991ofp\pybluez_521edbc9ad5c4270a89d76fba6a624ca
  Running command git clone --filter=blob:none -q https://github.com/pybluez/pybluez 'C:\Users\aaa\AppData\Local\Temp\pip-install-0c991ofp\pybluez_521edbc9ad5c4270a89d76fba6a624ca'
  Resolved https://github.com/pybluez/pybluez to commit 07ebef044195331a48bbb90a3acb911922048ba0
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: Pybluez
  Building wheel for Pybluez (setup.py) ... done
  Created wheel for Pybluez: filename=PyBluez-0.30-cp39-cp39-win_amd64.whl size=44980 sha256=9573d52c0f700da50c44ec5e9e26f10179ff78ff4b2b39e6788eac7793d4f7c9
  Stored in directory: C:\Users\aaa\AppData\Local\Temp\pip-ephem-wheel-cache-093g80tx\wheels\bc\7c\2f\4e387b5bfa0f5919fe04e222edc4d6c0e79e5f020ffbfeef98
Successfully built Pybluez
Installing collected packages: Pybluez
Successfully installed Pybluez-0.30
WARNING: You are using pip version 21.3.1; however, version 22.0.4 is available.
You should consider upgrading via the 'c:\program files\python39\python.exe -m pip install --upgrade pip' command.

Why don't you install wheel package?
In my windows 10 cmd, it worked.

D:\Users\aaa\Documents\temp>pip3 install wheel
Defaulting to user installation because normal site-packages is not writeable
Collecting wheel
  Using cached wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel
Successfully installed wheel-0.37.1
WARNING: You are using pip version 21.3.1; however, version 22.0.4 is available.
You should consider upgrading via the 'c:\program files\python39\python.exe -m pip install --upgrade pip' command.

D:\Users\aaa\Documents\temp>pip install git+https://github.com/pybluez/pybluez#egg=Pybluez
Defaulting to user installation because normal site-packages is not writeable
Collecting Pybluez
  Cloning https://github.com/pybluez/pybluez to c:\users\aaa\appdata\local\temp\pip-install-0c991ofp\pybluez_521edbc9ad5c4270a89d76fba6a624ca
  Running command git clone --filter=blob:none -q https://github.com/pybluez/pybluez 'C:\Users\aaa\AppData\Local\Temp\pip-install-0c991ofp\pybluez_521edbc9ad5c4270a89d76fba6a624ca'
  Resolved https://github.com/pybluez/pybluez to commit 07ebef044195331a48bbb90a3acb911922048ba0
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: Pybluez
  Building wheel for Pybluez (setup.py) ... done
  Created wheel for Pybluez: filename=PyBluez-0.30-cp39-cp39-win_amd64.whl size=44980 sha256=9573d52c0f700da50c44ec5e9e26f10179ff78ff4b2b39e6788eac7793d4f7c9
  Stored in directory: C:\Users\aaa\AppData\Local\Temp\pip-ephem-wheel-cache-093g80tx\wheels\bc\7c\2f\4e387b5bfa0f5919fe04e222edc4d6c0e79e5f020ffbfeef98
Successfully built Pybluez
Installing collected packages: Pybluez
Successfully installed Pybluez-0.30
WARNING: You are using pip version 21.3.1; however, version 22.0.4 is available.
You should consider upgrading via the 'c:\program files\python39\python.exe -m pip install --upgrade pip' command.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文