【问题标题】:pysqlcipher installation - SyntaxError: Missing parentheses in call to 'print'pysqlcipher 安装 - SyntaxError:调用“打印”时缺少括号
【发布时间】:2015-02-25 09:40:26
【问题描述】:

我有 Python 3.4.2,我尝试在装有 Windows 8 的 PC 上安装 pysqlcipher。 在我的命令提示符中输入以下代码后:

git clone https://github.com/leapcode/pysqlcipher/
cd pysqlcipher
python setup.py build_sqlcipher

我收到以下错误:

  File "setup.py", line 64
    print "CFLAGS", os.environ['CFLAGS']
                 ^
SyntaxError: Missing parentheses in call to 'print'

似乎是打印的问题。我有Python 3.4.2,这里使用的打印语法对应Python 2.X。我做了很多搜索,但没有找到任何解决方案。

有人知道如何使用 Python 3.4.2 安装 pysqlcipher 吗?

感谢您的帮助!

PS:我已经关注了这个tutorial,所有指示的事情都已经完成了。

【问题讨论】:

    标签: python python-3.x encryption sqlite sqlcipher


    【解决方案1】:

    看起来代码是为 Python 2 编写的。Python 3 包含一些更改,这些更改可能使某些 Python 2 与 Python 3 不兼容。

    Differences between python 2 and python 3

    您可以使用附带的 2to3 工具将 setup.pycross_bdist_wininst.py 转换为 python 3 兼容代码。

    只需运行2to3 -w setup.py2to3 -w cross_bdist_wininst.py 即可转换python 代码。自动转换工作得很好,但它确实错过了一次必要的转换。更改setup.py中的第209行

    -- if sources is None or type(sources) not in (ListType, TupleType):
    ++ if sources is None or type(sources) not in (List, Tuple):
    

    并删除第 30 行:

    -- from types import ListType, TupleType
    

    这应该允许你编译使用python setup.py build_sqlcipher

    【讨论】:

    • 非常感谢您的回答(我必须以 \Tools\Scripts 的方式添加到 %PATH% 以启用 2to3 工作)!现在我有一个新错误:src/connection.h:33:21: fatal error: sqlite3.h: No such file or directory #include "sqlite3.h" ^ compilation terminated. error: command 'C:\\MinGW\\bin\\gcc.exe' failed with exit status 1 你知道这个问题吗?
    猜你喜欢
    • 2016-12-08
    • 2022-01-14
    • 1970-01-01
    • 2016-06-15
    • 1970-01-01
    • 2018-02-12
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    相关资源
    最近更新 更多