适用于Python3的OSX HIDAPI安装(pip3故障排除):High-Sierra [英] OSX HIDAPI install for Python3 (pip3 troubleshooting): High-Sierra

查看:179
本文介绍了适用于Python3的OSX HIDAPI安装(pip3故障排除):High-Sierra的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OSX High-Sierra:已成功为python 2.7安装HIDAPI.今天已安装Python3:

OSX High-Sierra: HIDAPI was successfully installed for python 2.7. Python3 was installed today:

Users-MacBook-Air:~ user$ python3 --version
Python 3.7.5

在 python3安装后重新安装了HIDAPI:

HIDAPI was reinstalled after the python3 installation:

brew reinstall hidapi

此操作恢复了与python2一起使用的python脚本,并恢复了与条形码扫描仪脚本一起使用的

This restored the python script that was working with python2 and restored the barcode scanner script is working with:

sudo python2 test5.py

但是尝试使用python3运行脚本会返回错误:

However attempts to run the script with python3 returns an error:

sudo python3 test5.py

ModuleNotFoundError: No module named 'hid'

尝试通过pip3为python3 安装HIDAPI 失败:

An attempt install HIDAPI for python3 via pip3 failed:

pip3 install hidapi

是否有必要并且有可能使用PIP3为python3 安装HIDAPI ?

Is it necessary and possible to install HIDAPI with PIP3 for python3?

感谢您克服pip3错误的建议:谢谢

Suggestions to overcome pip3 errors are appeciated: thank you

sudo -H pip3 install hidapi返回:

Collecting hidapi
  Using cached https://files.pythonhosted.org/packages/c1/86/89df0e8890f96eeb5fb68d4ccb14cb38e2c2d2cfd7601ba972206acd9015/hidapi-0.7.99.post21.tar.gz
Requirement already satisfied: setuptools>=19.0 in /usr/local/lib/python3.7/site-packages (from hidapi) (41.6.0)
Building wheels for collected packages: hidapi
  Building wheel for hidapi (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/opt/python/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-9pj9tbky/hidapi/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-9pj9tbky/hidapi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/tmp/pip-wheel-sd48aazy --python-tag cp37
       cwd: /private/tmp/pip-install-9pj9tbky/hidapi/
  Complete output (23 lines):
  running bdist_wheel
  running build
  running build_ext
  cythoning hid.pyx to hid.c
  /private/tmp/pip-install-9pj9tbky/hidapi/.eggs/Cython-0.29.14-py3.7-macosx-10.13-x86_64.egg/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /private/tmp/pip-install-9pj9tbky/hidapi/hid.pyx
    tree = Parsing.p_module(s, pxd, full_module_name)
  building 'hid' extension
  creating build
  creating build/temp.macosx-10.13-x86_64-3.7
  creating build/temp.macosx-10.13-x86_64-3.7/hidapi
  creating build/temp.macosx-10.13-x86_64-3.7/hidapi/mac
  Compiling with an SDK that doesn't seem to exist: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
  Please check your Xcode installation
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -framework IOKit -framework CoreFoundation -Ihidapi/hidapi -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c hid.c -o build/temp.macosx-10.13-x86_64-3.7/hid.o
  clang: warning: -framework IOKit: 'linker' input unused [-Wunused-command-line-argument]
  clang: warning: -framework CoreFoundation: 'linker' input unused [-Wunused-command-line-argument]
  clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk' [-Wmissing-sysroot]
  In file included from hid.c:4:
  /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/include/python3.7m/Python.h:25:10: fatal error: 'stdio.h' file not found
  #include <stdio.h>
           ^~~~~~~~~
  1 error generated.
  error: command 'clang' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for hidapi
  Running setup.py clean for hidapi
Failed to build hidapi
Installing collected packages: hidapi
    Running setup.py install for hidapi ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/local/opt/python/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-9pj9tbky/hidapi/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-9pj9tbky/hidapi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-qsgmu9xu/install-record.txt --single-version-externally-managed --compile
         cwd: /private/tmp/pip-install-9pj9tbky/hidapi/
    Complete output (21 lines):
    running install
    running build
    running build_ext
    skipping 'hid.c' Cython extension (up-to-date)
    building 'hid' extension
    creating build
    creating build/temp.macosx-10.13-x86_64-3.7
    creating build/temp.macosx-10.13-x86_64-3.7/hidapi
    creating build/temp.macosx-10.13-x86_64-3.7/hidapi/mac
    Compiling with an SDK that doesn't seem to exist: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
    Please check your Xcode installation
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -framework IOKit -framework CoreFoundation -Ihidapi/hidapi -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c hid.c -o build/temp.macosx-10.13-x86_64-3.7/hid.o
    clang: warning: -framework IOKit: 'linker' input unused [-Wunused-command-line-argument]
    clang: warning: -framework CoreFoundation: 'linker' input unused [-Wunused-command-line-argument]
    clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk' [-Wmissing-sysroot]
    In file included from hid.c:4:
    /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/include/python3.7m/Python.h:25:10: fatal error: 'stdio.h' file not found
    #include <stdio.h>
             ^~~~~~~~~
    1 error generated.
    error: command 'clang' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/opt/python/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-9pj9tbky/hidapi/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-9pj9tbky/hidapi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-qsgmu9xu/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

pip3 install hidapi返回:

第一个错误是:

pip3 install hidapi returns:

The first error is:

  Building wheel for hidapi (setup.py) ... error

是什么导致此错误?以及如何克服?

What is causing this error? and how to overcome?

WARNING: The directory '/Users/user/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/Users/user/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting hidapi
  Downloading https://files.pythonhosted.org/packages/c1/86/89df0e8890f96eeb5fb68d4ccb14cb38e2c2d2cfd7601ba972206acd9015/hidapi-0.7.99.post21.tar.gz (51kB)
     |████████████████████████████████| 61kB 2.3MB/s 
Requirement already satisfied: setuptools>=19.0 in /usr/local/lib/python3.7/site-packages (from hidapi) (41.6.0)
Building wheels for collected packages: hidapi
  Building wheel for hidapi (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/opt/python/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-7lm8qgnn/hidapi/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-7lm8qgnn/hidapi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/tmp/pip-wheel-f9nrghcu --python-tag cp37
       cwd: /private/tmp/pip-install-7lm8qgnn/hidapi/
  Complete output (23 lines):
  running bdist_wheel
  running build
  running build_ext
  cythoning hid.pyx to hid.c
  /private/tmp/pip-install-7lm8qgnn/hidapi/.eggs/Cython-0.29.14-py3.7-macosx-10.13-x86_64.egg/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /private/tmp/pip-install-7lm8qgnn/hidapi/hid.pyx
    tree = Parsing.p_module(s, pxd, full_module_name)
  building 'hid' extension
  creating build
  creating build/temp.macosx-10.13-x86_64-3.7
  creating build/temp.macosx-10.13-x86_64-3.7/hidapi
  creating build/temp.macosx-10.13-x86_64-3.7/hidapi/mac
  Compiling with an SDK that doesn't seem to exist: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
  Please check your Xcode installation
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -framework IOKit -framework CoreFoundation -Ihidapi/hidapi -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c hid.c -o build/temp.macosx-10.13-x86_64-3.7/hid.o
  clang: warning: -framework IOKit: 'linker' input unused [-Wunused-command-line-argument]
  clang: warning: -framework CoreFoundation: 'linker' input unused [-Wunused-command-line-argument]
  clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk' [-Wmissing-sysroot]
  In file included from hid.c:4:
  /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/include/python3.7m/Python.h:25:10: fatal error: 'stdio.h' file not found
  #include <stdio.h>
           ^~~~~~~~~
  1 error generated.
  error: command 'clang' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for hidapi
  Running setup.py clean for hidapi
Failed to build hidapi
Installing collected packages: hidapi
    Running setup.py install for hidapi ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/local/opt/python/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-7lm8qgnn/hidapi/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-7lm8qgnn/hidapi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-9hm4q3f6/install-record.txt --single-version-externally-managed --compile
         cwd: /private/tmp/pip-install-7lm8qgnn/hidapi/
    Complete output (21 lines):
    running install
    running build
    running build_ext
    skipping 'hid.c' Cython extension (up-to-date)
    building 'hid' extension
    creating build
    creating build/temp.macosx-10.13-x86_64-3.7
    creating build/temp.macosx-10.13-x86_64-3.7/hidapi
    creating build/temp.macosx-10.13-x86_64-3.7/hidapi/mac
    Compiling with an SDK that doesn't seem to exist: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
    Please check your Xcode installation
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -framework IOKit -framework CoreFoundation -Ihidapi/hidapi -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c hid.c -o build/temp.macosx-10.13-x86_64-3.7/hid.o
    clang: warning: -framework IOKit: 'linker' input unused [-Wunused-command-line-argument]
    clang: warning: -framework CoreFoundation: 'linker' input unused [-Wunused-command-line-argument]
    clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk' [-Wmissing-sysroot]
    In file included from hid.c:4:
    /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/include/python3.7m/Python.h:25:10: fatal error: 'stdio.h' file not found
    #include <stdio.h>
             ^~~~~~~~~
    1 error generated.
    error: command 'clang' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/opt/python/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-7lm8qgnn/hidapi/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-7lm8qgnn/hidapi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-9hm4q3f6/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
Us

更新

模块:

pip3 install hidapi==0.7.99.post14

指示了一些构建错误,但最终指示:

indicated several build error but ultimately indicated:

Installing collected packages: Cython, hidapi
    Running setup.py install for hidapi ... done
Successfully installed Cython-0.29.14 hidapi-0.7.99.post14

经过测试的经过验证的python3进程HID流量.

Tested & Verified python3 process HID traffic.

推荐答案

https://github.com/trezor/cython-hidapi/issues/65 这似乎是软件中的错误.

https://github.com/trezor/cython-hidapi/issues/65 This seems to be bug in the software.

与此同时,棘手的解决方案是获取与Xcode 10捆绑在一起的MacOSX10.14 sdk.

Hacky solution in the meanwhile is to get the MacOSX10.14 sdk that is bundled with Xcode 10.

纠正措施

从以下位置安装 Xcode 10.1(与Sierra兼容) Apple网站确保将Xcode安装到/Applications目录.如果未安装到/Applications,请将其从/Downloads移至/Applications. 路径xcode-select -p应该使用

CORRECTIVE ACTION

Install Xcode 10.1 (High-Sierra Compatible) from the Apple website Be sure to install Xcode to /Applications directory. If it is not installed to /Applications move it from /Downloads to /Applications. The path xcode-select -p should be corrected using

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/

命令:

/usr/bin/xcodebuild -version

应返回:

Xcode 10.1
Build version 10B61

正确安装Xcode以支持pip3:

With Xcode properly in to support pip3:

$ pip3 install hidapi
Collecting hidapi
  Using cached https://files.pythonhosted.org/packages/c1/86/89df0e8890f96eeb5fb68d4ccb14cb38e2c2d2cfd7601ba972206acd9015/hidapi-0.7.99.post21.tar.gz
Requirement already satisfied: setuptools>=19.0 in ./env/lib/python3.7/site-packages (from hidapi) (41.2.0)
Installing collected packages: hidapi
  Running setup.py install for hidapi ... done
Successfully installed hidapi-0.7.99.post21

这篇关于适用于Python3的OSX HIDAPI安装(pip3故障排除):High-Sierra的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆