pip install python-adb 失败

pip install python-adb failed

我想使用 pip V9.0.3 安装 Python-adb。

当我尝试安装 python-adb 时,我总是遇到与底部相同的错误。
我还尝试在 pip/pip3.

上使用具有管理员权限的 CMD 安装它

我已经尝试过的:
- CMD with/without 管理员权限
- pip/pip3 安装
- 为 C++ 错误安装了 mingw

我目前在 Windows 7 64Bit

上使用 Python3.6

输出:

Collecting python-adb
  Using cached python_adb-1.1.1-py3-none-any.whl
Requirement already satisfied: libusb1>=1.0.16 in c:\users\alex\appdata\local\programs\python\python
36\lib\site-packages (from python-adb)
Collecting M2Crypto>=0.21.1 (from python-adb)
  Using cached M2Crypto-0.29.0.tar.gz
Requirement already satisfied: six in c:\users\alex\appdata\local\programs\python\python36\lib\site-
packages (from python-adb)
Installing collected packages: M2Crypto, python-adb
  Running setup.py install for M2Crypto ... error
    Complete output from command c:\users\alex\appdata\local\programs\python\python36\python.exe -u
-c "import setuptools, tokenize;__file__='C:\Users\Alex\AppData\Local\Temp\pip-build-nwjmz2a0\
\M2Crypto\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n')
;f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Alex\AppData\Local\Temp\
pip-1s9ml6zw-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    copying M2Crypto\ASN1.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\AuthCookie.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\BIO.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\BN.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\callback.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\DH.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\DSA.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\EC.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\Engine.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\Err.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\EVP.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\ftpslib.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\httpslib.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\m2.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\m2crypto.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\m2urllib.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\m2urllib2.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\m2xmlrpclib.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\Rand.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\RC4.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\RSA.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\six.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\SMIME.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\threading.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\util.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\X509.py -> build\lib.win-amd64-3.6\M2Crypto
    copying M2Crypto\__init__.py -> build\lib.win-amd64-3.6\M2Crypto
    creating build\lib.win-amd64-3.6\M2Crypto\SSL
    copying M2Crypto\SSL\cb.py -> build\lib.win-amd64-3.6\M2Crypto\SSL
    copying M2Crypto\SSL\Checker.py -> build\lib.win-amd64-3.6\M2Crypto\SSL
    copying M2Crypto\SSL\Cipher.py -> build\lib.win-amd64-3.6\M2Crypto\SSL
    copying M2Crypto\SSL\Connection.py -> build\lib.win-amd64-3.6\M2Crypto\SSL
    copying M2Crypto\SSL\Context.py -> build\lib.win-amd64-3.6\M2Crypto\SSL
    copying M2Crypto\SSL\Session.py -> build\lib.win-amd64-3.6\M2Crypto\SSL
    copying M2Crypto\SSL\SSLServer.py -> build\lib.win-amd64-3.6\M2Crypto\SSL
    copying M2Crypto\SSL\ssl_dispatcher.py -> build\lib.win-amd64-3.6\M2Crypto\SSL
    copying M2Crypto\SSL\timeout.py -> build\lib.win-amd64-3.6\M2Crypto\SSL
    copying M2Crypto\SSL\TwistedProtocolWrapper.py -> build\lib.win-amd64-3.6\M2Crypto\SSL
    copying M2Crypto\SSL\__init__.py -> build\lib.win-amd64-3.6\M2Crypto\SSL
    running build_ext
    building 'M2Crypto._m2crypto' extension
    creating build\temp.win-amd64-3.6
    creating build\temp.win-amd64-3.6\Release
    creating build\temp.win-amd64-3.6\Release\SWIG
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /
GL /DNDEBUG /MD -Ic:\users\alex\appdata\local\programs\python\python36\include -Ic:\users\alex\appda
ta\local\programs\python\python36\include -IC:\Users\Alex\AppData\Local\Temp\pip-build-nwjmz2a0\M2Cr
ypto\SWIG "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x8
6)\Windows Kits\include.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits.1\include\sha
red" "-IC:\Program Files (x86)\Windows Kits.1\include\um" "-IC:\Program Files (x86)\Windows Kits
.1\include\winrt" /TcSWIG/_m2crypto_wrap.c /Fobuild\temp.win-amd64-3.6\Release\SWIG/_m2crypto_wrap.o
bj -D_CRT_SECURE_NO_WARNINGS -DTHREADING
    _m2crypto_wrap.c
    SWIG/_m2crypto_wrap.c(3557): fatal error C1083: Cannot open include file: 'openssl/err.h': No su
ch file or directory
    error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.ex
e' failed with exit status 2

    ----------------------------------------
Command "c:\users\alex\appdata\local\programs\python\python36\python.exe -u -c "import setuptools, t
okenize;__file__='C:\Users\Alex\AppData\Local\Temp\pip-build-nwjmz2a0\M2Crypto\setup.py';f=g
etattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(
code, __file__, 'exec'))" install --record C:\Users\Alex\AppData\Local\Temp\pip-1s9ml6zw-record\inst
all-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\A
lex\AppData\Local\Temp\pip-build-nwjmz2a0\M2Crypto\

显然 M2Crypto(这是您的安装过程失败的地方)在 Windows 上安装起来有点困难,但是 unofficial binaries available (though that is a dated question), and the package's own install instructions include a section on Windows installation

更有希望的是,还安装了项目 here, which also has Windows instructions. But for that you'll need to have SWIG 的克隆。

第三个选项是这对 (32-bit, 64-bit) 包,它们是 M2Crypto 的克隆,专门为 Windows 制作,但我不确定 up-to-date他们是(最后一次提交是在 2014 年,所以现在可能对原始项目有很多更改)。

目前没有可用于 PyADB 的 Debian 包。 (即将修复……)

[+] Debian Package: # #$ sudo dpkg -i python-pyadb_0.1.0-1_all.deb #Selecting previously unselected package python-pyadb. #(Leyendo la base de datos … 322039 ficheros o directorios instalados actualmente.) #Desempaquetando python-pyadb (de python-pyadb_0.1.0-1_all.deb) … #Configurando python- pyadb (0.1.0-1) … #

[+] easy_install

$ sudo easy_install pyadb Searching for pyadb … Processing dependencies for pyadb Finished processing dependencies for pyadb $

[+] setup.py

$ python setup.py build running build running build_py creating build creating build/lib.linux-i686-2.7 creating build/lib.linux-i686-2.7/pyadb copying pyadb/adb.py -> build/lib.linux-i686-2.7/pyadb copying pyadb/__init__.py -> build/lib.linux-i686-2.7/pyadb $ sudo python setup.py install running install running build running build_py running install_lib running install_egg_info Removing /usr/local/lib/python2.7/dist-packages/pyadb-0.1.1.egg-info Writing /usr/local/lib/python2.7/dist-packages/pyadb-0.1.1.egg-info $

更多说明:http://wiki.python.org/moin/CheeseShopTutorial

用法:

$ python Python 2.7.3 (default, Jun 15 2012, 18:14:05) [GCC 4.7.0] on linux2 Type “help”, “copyright”, “credits” or “license” for more information. >>> from pyadb import ADB >>> adb = ADB(‘~/android/platform-tools/adb’) >>> print adb.pyadb_version() 0.1.1 >>> quit() $

您可以在“examples/whatsapp.py”中查看“完整”示例