2016-09-22 125 views
0

的Spynner文档说,它支持Python> = 26,但在安装过程中,我得到以下错误:如何让Python 2.7包(Spynner)与Python 3一起工作?

(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技巧,我可以做到这一点与Python 3一起工作,还是我必须去手动更正有问题的代码?

Cheers

+0

奇......从GitHub源看起来OK ... https://github.com/msanders/autopy/blob/master/setup的.py#L56。也许你可以试着直接从github上'pip install'呢? 'pip3安装git + https:// github.com/msanders/autopy.git'和_then_ install'spynner'('pip3 install spynner')? – mgilson

+0

不幸的是,这产生了另一个错误。如果(mod == NULL)返回;/*错误*/ ^ src/autopy-mouse-module.c:87:3:错误:非void函数'initmouse'应该返回一个值[-Wreturn-type] return; ^ 生成2个错误。 错误:命令'/ usr/bin/clang'失败,退出状态为1 –

回答

0

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

2to3 is a Python program that reads Python 2.x source code and applies a series of fixers to transform it into valid Python 3.x code. The standard library contains a rich set of fixers that will handle almost all code. 2to3 supporting library lib2to3 is, however, a flexible and generic library, so it is possible to write your own fixers for 2to3. lib2to3 could also be adapted to custom applications in which Python code needs to be edited automatically.

相关问题