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

Posted 走在成长路上的自己

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

以上是关于Robot framework安装python3.7导入HttpLibrary.HTTP报错的主要内容,如果未能解决你的问题,请参考以下文章

Windows系统 - python3(3.7以上版本)部署自动化框架robot framework

Robot Framework安装

Python + Robot Framework 环境搭建

pycharm下robot framework环境搭建,基于python版本3.6

Robot Framework IDE (RIDE) 执行配置文件未显示

python3+Robot Framework+PyCharm自动化测试框架设计