pysqlcipher installation - SyntaxError: Missing parentheses in call to 'print'

FrancNovation picture FrancNovation · Feb 25, 2015 · Viewed 8.9k times · Source

I have Python 3.4.2, and I try to install pysqlcipher on my PC with windows 8. After having entered the code below in my command prompt:

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

I’m getting the following error:

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

It seems to be a problem with print. I have Python 3.4.2, and the print syntax used here corresponds to Python 2.X. I have done lot of searching but I haven’t found any solution.

Does someone know how to install pysqlcipher with Python 3.4.2?

Thank you for your help!

PS: I have already followed this tutorial and all things indicated have been accomplished.

Answer

mpursuit picture mpursuit · Feb 25, 2015

It looks like the code is written for Python 2. Python 3 contains several changes that can make some Python 2 incompatible with Python 3.

Differences between python 2 and python 3

You can use the included 2to3 tool to convert the setup.py and cross_bdist_wininst.py into python 3 compatible code.

Just run 2to3 -w setup.py and 2to3 -w cross_bdist_wininst.py to convert the python code. The automatic convert works quite well but it does miss out one conversion that is necessary. Change line 209 in setup.py

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

and remove line 30:

-- from types import ListType, TupleType

This should then allow you to compile the using python setup.py build_sqlcipher