Robot framework安装python3.7导入HttpLibrary.HTTP报错

报错信息:

20200106 18:23:28.178 [WARN]: Importing test library "HttpLibrary.HTTP" failed

Traceback (most recent call last):
Importing test library 'HttpLibrary.HTTP' failed: SyntaxError: invalid syntax (__init__.py, line 16)
Traceback (most recent call last):
File "D:\Python37\lib\site-packages\robotide\lib\robot\utils\importer.py", line 153, in _import
return __import__(name, fromlist=fromlist)
PYTHONPATH:
D:\Python37\python37.zip
D:\Python37\DLLs
D:\Python37\lib
D:\Python37
D:\Python37\lib\site-packages
D:\Python37\lib\site-packages\win32
D:\Python37\lib\site-packages\win32\lib
D:\Python37\lib\site-packages\Pythonwin
D:\Python37\lib\site-packages\robotide\spec
D:\Python37\lib\site-packages\robotide\lib
D:\Python37\lib\site-packages\robotide\contrib\testrunner\../../lib
D:\Python37\lib\site-packages\robotide\contrib\testrunner\../../lib
File "D:\Python37\lib\site-packages\robotide\spec\librarymanager.py", line 87, in _fetch_keywords
return get_import_result(path, library_args)
File "D:\Python37\lib\site-packages\robotide\spec\libraryfetcher.py", line 24, in get_import_result
lib = robotapi.TestLibrary(path, args)
File "D:\Python37\lib\site-packages\robotide\lib\robot\running\testlibraries.py", line 50, in TestLibrary
return_source=True)
File "D:\Python37\lib\site-packages\robotide\lib\robot\utils\importer.py", line 72, in import_class_or_module
self._raise_import_failed(name, err)
File "D:\Python37\lib\site-packages\robotide\lib\robot\utils\importer.py", line 109, in _raise_import_failed
raise DataError('\n'.join(msg))

 

 

问题原因:不兼容

解决方法:

1.检查livetest,json是否已成功安装

 

(如果livetest也安装失败,则

下载https://files.pythonhosted.org/packages/de/77/7ab378ff9e62013f1756b64b1553e126ba7b3f3598bc9c5c8fc508c13d55/livetest-0.5.tar.gz

2.修改  \livetest-0.5\livetest\__init__.py 

修改import httplib -> import http.client as httplib
修改import urlparse -> import urllib.parse
修改from Cookie import BaseCookie, CookieError -> import http.cookiejar

修改XXXError, e 为XXXError as e

3.修改 \livetest-0.5\setup.py

修改long_description=file('README.rst').read() -> long_description=open('README.rst').read()
修改version=livetest.__version__ -> version='0.5'
修改author_email=livetest.__author__ -> author_email='storborg@mit.edu'

4.在cmd中切换路径到 \livetest-0.5,执行 python setup.py install,安装成功。

)

 

 

2.修改__init__.py (文件路径:C:\Python37\Lib\site-packages\HttpLibrary)

修改from urlparse import urlparse ->from urllib.parse import urlparse 

修改except ValueError, e为 except ValueError as e (共两处)

3. 重启ride,导入正常。

转自:https://www.cnblogs.com/joker666/p/11583309.html

posted @ 2020-01-07 11:52  走在成长路上的自己  阅读(2693)  评论(0编辑  收藏  举报