[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:\Users\xx00>pip install uiautomator2
 2 Collecting uiautomator2
 3 c:\python27\lib\site-packages\pip-9.0.1-py2.7.egg\pip\_vendor\requests\packages\urllib3\util\ssl_.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:\python27\lib\site-packages\pip-9.0.1-py2.7.egg\pip\_vendor\requests\packages\urllib3\util\ssl_.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:\Python27\Scripts\pip-script.py", line 9, in <module>
43     load_entry_point('pip==9.0.1', 'console_scripts', 'pip')()
44   File "c:\python27\lib\site-packages\pip-9.0.1-py2.7.egg\pip\__init__.py", line 233, in main
45     return command.main(cmd_args)
46   File "c:\python27\lib\site-packages\pip-9.0.1-py2.7.egg\pip\basecommand.py", line 252, in main
47     pip_version_check(session)
48   File "c:\python27\lib\site-packages\pip-9.0.1-py2.7.egg\pip\utils\outdated.py", line 102, in pip_version_check
49     installed_version = get_installed_version("pip")
50   File "c:\python27\lib\site-packages\pip-9.0.1-py2.7.egg\pip\utils\__init__.py", line 838, in get_installed_version
51     working_set = pkg_resources.WorkingSet()
52   File "c:\python27\lib\site-packages\pip-9.0.1-py2.7.egg\pip\_vendor\pkg_resources\__init__.py", line 644, in __init__
53     self.add_entry(entry)
54   File "c:\python27\lib\site-packages\pip-9.0.1-py2.7.egg\pip\_vendor\pkg_resources\__init__.py", line 700, in add_entry
55     for dist in find_distributions(entry, True):
56   File "c:\python27\lib\site-packages\pip-9.0.1-py2.7.egg\pip\_vendor\pkg_resources\__init__.py", line 1949, in find_eggs_in_zip
57     if metadata.has_metadata('PKG-INFO'):
58   File "c:\python27\lib\site-packages\pip-9.0.1-py2.7.egg\pip\_vendor\pkg_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:\python27\lib\site-packages\pip-9.0.1-py2.7.egg\pip\_vendor\pkg_resources\__init__.py", line 1823, in _has
61     return zip_path in self.zipinfo or zip_path in self._index()
62   File "c:\python27\lib\site-packages\pip-9.0.1-py2.7.egg\pip\_vendor\pkg_resources\__init__.py", line 1703, in zipinfo
63     return self._zip_manifests.load(self.loader.archive)
64   File "c:\python27\lib\site-packages\pip-9.0.1-py2.7.egg\pip\_vendor\pkg_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:\Users\xxoo>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:\python27\lib\site-packages\uiautomator-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:\Users\xxoo>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:\python27\lib\site-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.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM