Python版本低于2.7.5下运行正则报错sre_constants.error: nothing to repeat
来源:互联网 发布:费米估算法 编辑:程序博客网 时间:2024/05/23 01:12
前言
在linux服务器安装配置爬虫相关环境时,python版本是2.7.3,在安装Twisted模块时,安装其依赖包m2r时报错:sre_constants.error: nothing to repeat
!
解决方案
报错位置在m2r/m2r.py文件下:
rest_role = re.compile(r':.*?:`.*?`|`[^`]+`:.*?:')rest_link = re.compile(r'`[^`]*?`_')inline_math = re.compile(r'`\$(.*)?\$`')eol_literal_marker = re.compile(r'(\s+)?::\s*$')
中inline_math = re.compile(r'`\$(.*)?\$`')
这一句!
因为python模块re对“*”
匹配处理异常导致语句执行失效,导致报错!
所以在Python 版本低于2.7.5时,在遇到需要正则匹配“*”
时需要做转换处理!
在stackoverflow找到一个回答:
regex error - nothing to repeat
参考第二个回答,我们将原来的
inline_math = re.compile(r'`\$(.*)?\$`')
替换为;
inline_math = re.compile(r'`\$(.[a-zA-z\s]*)?\$`')
然后重新安装,编译通过,安装成功!
阅读全文
1 0
- Python版本低于2.7.5下运行正则报错sre_constants.error: nothing to repeat
- python3.3 django错误处理“sre_constants.error: nothing to repeat”
- python3错误处理“sre_constants.error: nothing to repeat”
- js正则表达式报Nothing to repeat
- python的正则出错——raise error:("multiple repeat ")
- Android 分包导致低于5.0版本报错ClassNotFoundException
- sre_constants.error: unbalanced parenthesis
- eclipse下运行android项目报错:Conversion to Dalvik format failed with error 1解决办法
- CentOS:Error: Nothing to do
- Sublime3下运行含有中文字符的Python程序报错:[Decode error
- xShell运行Python脚本报错 Python script error 80040154
- 安卓开发环境ADT报错:adt版本低于sdk版本,请升级
- ng-repeat报错
- Android——eclipse下运行android项目报错 Conversion to Dalvik format failed with error 1解决
- Python 使用 Sublime text 3 运行报错 [Decode error
- Android Studio 2.3 版本下select deployment target nothing to show
- linux(ubuntu)下用eclipse运行C,可是一直提示nothing to build for project ProjectName
- python运行报错
- 百度之星初赛B 度度熊的交易计划(最小费用可行流)
- 数据结构--排序
- create_pascal_tf_record.py 代码解析
- 常用网址
- 虚拟直播间实施方案-校园虚拟蓝箱演播室系统
- Python版本低于2.7.5下运行正则报错sre_constants.error: nothing to repeat
- 几个常用的网址
- PAT乙级 1011. A+B和C (15)
- 应用类型
- 你应该知道的那些超时设置或默认参数
- request_irq()
- iOS开发使用Git的使用
- I/O流 cat
- 欢迎使用CSDN-markdown编辑器