zoukankan      html  css  js  c++  java
  • [Android自动化] 在 pip-9.0.1 版本情况下安装 uiautomator2 报错的解决办法

    1、在命令窗口中使用命令: pip install uiautomator2 时报 pip 版本过低,需要先升级 pip 版本,理论上会按照提示进行升级 pip 操作,但执行升级命令时到最后却还是报错,仍提示 pip 版本过低

    解决办法:

    直接先在命令窗口中执行命令: python -m pip install --upgrade pip setuptools wheel   待提示成功安装即可

    1 Installing collected packages: setuptools, wheel
    2   Found existing installation: setuptools 28.8.0
    3     Uninstalling setuptools-28.8.0:
    4       Successfully uninstalled setuptools-28.8.0
    5 Successfully installed setuptools-40.0.0 wheel-0.31.1

    此时再安装 uiautomator2 即可成功(都不需要升级 pip 版本号)

     1 C:Usersxx00>pip install uiautomator2
     2 Collecting uiautomator2
     3 c:python27libsite-packagespip-9.0.1-py2.7.eggpip\_vendor
    equestspackagesurllib3utilssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
     4   SNIMissingWarning
     5 c:python27libsite-packagespip-9.0.1-py2.7.eggpip\_vendor
    equestspackagesurllib3utilssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
     6   InsecurePlatformWarning
     7 Collecting retry>=0.9.2 (from uiautomator2)
     8   Using cached https://files.pythonhosted.org/packages/4b/0d/53aea75710af4528a25ed6837d71d117602b01946b307a3912cb3cfcbcba/retry-0.9.2-py2.py3-none-any.whl
     9 Collecting humanize (from uiautomator2)
    10 Collecting whichcraft (from uiautomator2)
    11   Using cached https://files.pythonhosted.org/packages/60/8a/5c52e30e11672f7e3aa61f348ddae443d122bcd96bc8b785ac76dbae944b/whichcraft-0.4.1-py2.py3-none-any.whl
    12 Collecting fire (from uiautomator2)
    13 Collecting six (from uiautomator2)
    14   Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
    15 Collecting progress>=1.3 (from uiautomator2)
    16 Collecting requests>=2.7.0 (from uiautomator2)
    17   Using cached https://files.pythonhosted.org/packages/65/47/7e02164a2a3db50ed6d8a6ab1d6d60b69c4c3fdf57a284257925dfc12bda/requests-2.19.1-py2.py3-none-any.whl
    18 Collecting decorator>=3.4.2 (from retry>=0.9.2->uiautomator2)
    19   Using cached https://files.pythonhosted.org/packages/bc/bb/a24838832ba35baf52f32ab1a49b906b5f82fb7c76b2f6a7e35e140bac30/decorator-4.3.0-py2.py3-none-any.whl
    20 Collecting py<2.0.0,>=1.4.26 (from retry>=0.9.2->uiautomator2)
    21   Using cached https://files.pythonhosted.org/packages/f3/bd/83369ff2dee18f22f27d16b78dd651e8939825af5f8b0b83c38729069962/py-1.5.4-py2.py3-none-any.whl
    22 Collecting urllib3<1.24,>=1.21.1 (from requests>=2.7.0->uiautomator2)
    23   Using cached https://files.pythonhosted.org/packages/bd/c9/6fdd990019071a4a32a5e7cb78a1d92c53851ef4f56f62a3486e6a7d8ffb/urllib3-1.23-py2.py3-none-any.whl
    24 Collecting chardet<3.1.0,>=3.0.2 (from requests>=2.7.0->uiautomator2)
    25   Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
    26 Collecting certifi>=2017.4.17 (from requests>=2.7.0->uiautomator2)
    27   Using cached https://files.pythonhosted.org/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl
    28 Collecting idna<2.8,>=2.5 (from requests>=2.7.0->uiautomator2)
    29   Using cached https://files.pythonhosted.org/packages/4b/2a/0276479a4b3caeb8a8c1af2f8e4355746a97fab05a372e4a2c6a6b876165/idna-2.7-py2.py3-none-any.whl
    30 Installing collected packages: decorator, py, retry, humanize, whichcraft, six, fire, progress, urllib3, chardet, certifi, idna, requests, uiautomator2
    31   Found existing installation: py 1.4.20
    32     Uninstalling py-1.4.20:
    33       Successfully uninstalled py-1.4.20
    34   Found existing installation: urllib3 1.8.2
    35     Uninstalling urllib3-1.8.2:
    36       Successfully uninstalled urllib3-1.8.2
    37   Found existing installation: requests 2.3.0
    38     Uninstalling requests-2.3.0:
    39       Successfully uninstalled requests-2.3.0
    40 Successfully installed certifi-2018.4.16 chardet-3.0.4 decorator-4.3.0 fire-0.1.3 humanize-0.5.1 idna-2.7 progress-1.4 py-1.5.4 requests-2.19.1 retry-0.9.2 six-1.11.0 uiautomator2-0.1.2 urllib3-1.23 whichcraft-0.4.1
    41 Traceback (most recent call last):
    42   File "C:Python27Scriptspip-script.py", line 9, in <module>
    43     load_entry_point('pip==9.0.1', 'console_scripts', 'pip')()
    44   File "c:python27libsite-packagespip-9.0.1-py2.7.eggpip\__init__.py", line 233, in main
    45     return command.main(cmd_args)
    46   File "c:python27libsite-packagespip-9.0.1-py2.7.eggpipasecommand.py", line 252, in main
    47     pip_version_check(session)
    48   File "c:python27libsite-packagespip-9.0.1-py2.7.eggpiputilsoutdated.py", line 102, in pip_version_check
    49     installed_version = get_installed_version("pip")
    50   File "c:python27libsite-packagespip-9.0.1-py2.7.eggpiputils\__init__.py", line 838, in get_installed_version
    51     working_set = pkg_resources.WorkingSet()
    52   File "c:python27libsite-packagespip-9.0.1-py2.7.eggpip\_vendorpkg_resources\__init__.py", line 644, in __init__
    53     self.add_entry(entry)
    54   File "c:python27libsite-packagespip-9.0.1-py2.7.eggpip\_vendorpkg_resources\__init__.py", line 700, in add_entry
    55     for dist in find_distributions(entry, True):
    56   File "c:python27libsite-packagespip-9.0.1-py2.7.eggpip\_vendorpkg_resources\__init__.py", line 1949, in find_eggs_in_zip
    57     if metadata.has_metadata('PKG-INFO'):
    58   File "c:python27libsite-packagespip-9.0.1-py2.7.eggpip\_vendorpkg_resources\__init__.py", line 1463, in has_metadata
    59     return self.egg_info and self._has(self._fn(self.egg_info, name))
    60   File "c:python27libsite-packagespip-9.0.1-py2.7.eggpip\_vendorpkg_resources\__init__.py", line 1823, in _has
    61     return zip_path in self.zipinfo or zip_path in self._index()
    62   File "c:python27libsite-packagespip-9.0.1-py2.7.eggpip\_vendorpkg_resources\__init__.py", line 1703, in zipinfo
    63     return self._zip_manifests.load(self.loader.archive)
    64   File "c:python27libsite-packagespip-9.0.1-py2.7.eggpip\_vendorpkg_resources\__init__.py", line 1643, in load
    65     mtime = os.stat(path).st_mtime
    66 WindowsError: [Error 2] : 'C:\Python27\lib\site-packages\urllib3-1.8.2-py2.7.egg'

    此时再同时查看 uiautomator 和 uiautomator2的版本号,确认两个安装情况(显示如下即为成功)

     1 C:Usersxxoo>pip show uiautomator
     2 Name: uiautomator
     3 Version: 0.1.32
     4 Summary: Python Wrapper for Android UiAutomator test tool
     5 Home-page: https://github.com/xiaocong/uiautomator
     6 Author: youwei deng
     7 Author-email: xiaocong@gmail.com
     8 License: MIT
     9 Location: c:python27libsite-packagesuiautomator-0.1.32-py2.7.egg
    10 Requires: urllib3
    11 You are using pip version 9.0.1, however version 18.0 is available.
    12 You should consider upgrading via the 'python -m pip install --upgrade pip' command.
    13 
    14 C:Usersxxoo>pip show uiautomator2
    15 Name: uiautomator2
    16 Version: 0.1.2
    17 Summary: Python Wrapper for Android UiAutomator2 test tool
    18 Home-page: https://github.com/codeskyblue/uiautomator2
    19 Author: codeskyblue
    20 Author-email: codeskyblue@gmail.com
    21 License: MIT
    22 Location: c:python27libsite-packages
    23 Requires: retry, humanize, whichcraft, fire, six, progress, requests
    24 You are using pip version 9.0.1, however version 18.0 is available.
    25 You should consider upgrading via the 'python -m pip install --upgrade pip' command.
  • 相关阅读:
    Windows7下面手把手教你安装Django
    windows系统下Python环境的搭建
    PHP、Java、Python、C、C++ 这几种编程语言都各有什么特点或优点
    结构化程序设计 ?
    编译性语言、解释性语言和脚本语言
    在linux中关闭防火墙
    Linux下Apache服务的查看和启动
    AWS中,如果使用了ELB,出现outofservice
    亚马逊的PuTTY连接AWS出现network error connection refused,终极解决方案。
    9.Node.js 包管理器npm
  • 原文地址:https://www.cnblogs.com/aziji/p/9448523.html
Copyright © 2011-2022 走看看