首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何让Python 2.7包(Spynner)与Python 3协同工作?

如何让Python 2.7包(Spynner)与Python 3协同工作?
EN

Stack Overflow用户
提问于 2016-09-22 15:30:55
回答 1查看 488关注 0票数 0

Spynner文档说它支持Python >=26,但在安装过程中我得到了以下错误:

代码语言:javascript
复制
(spynner) spynner$ pip3 install spynner
Requirement already satisfied (use --upgrade to upgrade): spynner in /Users/spynner/Envs/spynner/lib/python3.4/site-packages/spynner-2.19-py3.4.egg
Collecting six (from spynner)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting beautifulsoup4 (from spynner)
  Using cached beautifulsoup4-4.5.1-py3-none-any.whl
Collecting unittest2 (from spynner)
  Using cached unittest2-1.1.0-py2.py3-none-any.whl
Collecting pyquery (from spynner)
  Using cached pyquery-1.2.13.tar.gz
Collecting autopy (from spynner)
  Using cached autopy-0.51.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/zl/dpw1svbx2qjbl549qvzq2r640000gn/T/pip-build-3rvrid_c/autopy/setup.py", line 50
        print 'Updating __init__.py'
                               ^
    SyntaxError: Missing parentheses in call to 'print'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/zl/dpw1svbx2qjbl549qvzq2r640000gn/T/pip-build-3rvrid_c/autopy/

所以看起来其中一个包是为2.7编写的。

有没有一些Python技巧可以让它在Python3中工作,或者我必须手动更正有问题的代码?

干杯

EN

回答 1

Stack Overflow用户

发布于 2016-09-22 15:37:46

您需要更正有问题的代码。有一些自动化的工具可以帮助您做到这一点,例如2to3

Python2to3是一个

程序,它读取Python2.x源代码并应用一系列修复程序将其转换为有效的Python3.x代码。标准库包含一组丰富的修复程序,它们可以处理几乎所有的代码。然而,2to3支持库lib2to3是一个灵活和通用的库,因此可以为2to3编写自己的修复器。lib2to3还可以适应需要自动编辑Python代码的自定义应用程序。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39632870

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档