2016-09-22 123 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.

相關問題