Cannot install PySpatiaLite module ("SyntaxError: Missing parentheses in call to 'print' ") - python

When I run
python3 -m pip install pyspatialite
I get the following error:
Collecting pyspatialite
Using cached https://files.pythonhosted.org/packages/cc/2a/ffb126f3e8890ab0da951a83906e54528a13ce4b913303dea8bed904e160/pyspatialite-3.0.1-alpha-0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-14jnmfoo/pyspatialite/setup.py", line 66
print "Is sphinx installed? If not, try 'sudo easy_install sphinx'."
^
SyntaxError: Missing parentheses in call to 'print'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-14jnmfoo/pyspatialite/
I don't understand the issue. Is there a syntax error in the module PySpatiaLite? What do I do about it?
I am using Python 3.5 and Linux Bash Shell in Windows 10. If there is any additional info needed, let me know in the comments and I will edit the question.

Seems like it is a known issue in python 3:
https://github.com/lokkju/pyspatialite/issues/27

print "Is sphinx installed? If not, try 'sudo easy_install sphinx'."
Seems that this library is written in Python 2.7 as they are using the Python 2 print statement. When pip3 runs the libraries setup.py the error you are receiving:
SyntaxError: Missing parentheses in call to 'print'
Is entirely expected as the correct Python 3 syntax would be:
print("Is sphinx installed? If not, try 'sudo easy_install sphinx'.")
You can either switch to Python 2.7 for writing code to interface with this, or reach out to the contributors for assistance. Looking at their documentation on PyPi (https://pypi.org/project/pyspatialite/) it looks like the project is still in Alpha and has not been updated with a new release since 2013. I wouldn't expect much in terms of Python 3 compatibility without forking the source and correcting it yourself.
EDIT
Looking at the GitHub commits (https://github.com/lokkju/pyspatialite/commits/master) a small amount of commits have been merged in since 2013, but I would still not expect Python 3 support.

Related

Problems with Python: ImportError: No module named ... [Linux]

I am a noob with installing python programs. I know there are a lot of Questions like this here, I have tried to find a solution for my problem but I can't fix it.
First of all, I am trying to install a program called Qarq. The readme says:
Setup
In order to get qark running, it must be present on your python path. If not, it may lead to module not found errors. This can be done for your current shell by running the following:
export PYTHONPATH={qark root directory}:$PYTHONPATH
Well, I type the command. I check the variable with an echo and I can see the directory in the variable. However, I type "python setup.py install" and I get this error:
santoku#santoku-PC:~/qark$ python setup.py install
Traceback (most recent call last):
File "setup.py", line 1, in <module>
from setuptools import setup, find_packages
ImportError: No module named setuptools
Then, I read in a question here that you must install setuptools, so I did it. I ran the next command:
sudo apt-get install python-setuptools
But the problem is still there, I try to run "python setup.py install" and I get the same error.
On the other hand, the readme says you only need to execute "$ python qarkMain.py". I do that and I get the same error with different module:
santoku#santoku-PC:~/qark/qark$ python qarkMain.py install
Traceback (most recent call last):
File "qarkMain.py", line 30, in <module>
from qark.modules.IssueType import IssueSeverity
ImportError: No module named qark.modules.IssueType
I am using Python 2.7.12 (default, Nov 12 2016, 01:02:22) [GCC 4.8.4] on linux2. (Ubuntu 14.04.5 LTS)
I have tried to install qark on Ubuntu 16.04.1 LTS and it worked perfectly. I didn't need to install setuptools. Both have the same python version.
I guess the problem is python can't find the modules, maybe I have to move the qark directory to another directory.
I think that's all, if you need more extra information just ask me.
I need your help, I am sure my problem is a foolishness and easy to fix. But I am a noob with python and I don't have any idea.
Thank you very much and thanks in advance.
Sorry for my English, I am not a native speaker.
EDIT: I found a solution, I tried to install again the OS and now python works properly, I don't know if I broke python or I did something bad. Anyway, Thanks.
i could get it work typing this:
1) PYTHONPATH=\home\santoku\qark\qark\:$PYTHONPATH
then just type:
2) python qarkMain.py

Install requirements.txt error, syntax error - python2

I have this requirements.txt file:
Django==1.9.4
EbookLib==0.15
SpeechRecognition==3.3.3
argcomplete==1.1.0
argparse==1.2.1
beautifulsoup4==4.4.1
chardet==2.3.0
lxml==3.5.0
pdfminer==20140328
python-docx==0.8.5
python-pptx==0.5.8
requests==2.9.1
textract==1.4.0
wsgiref==0.1.2
xlrd==0.9.4
When I run $pip install -r requirements.txt in my virtualenv i have the following error:
Collecting pdfminer==20140328 (from -r requirements.txt (line 9))
Using cached pdfminer-20140328.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "/tmp/pip-build-ymmlp5sc/pdfminer/setup.py", line 3, in <module>
from pdfminer import __version__
File "/tmp/pip-build-ymmlp5sc/pdfminer/pdfminer/__init__.py", line 5
print __version__
^
SyntaxError: Missing parentheses in call to 'print'
It's seems that this file is written in python2.
Is there a way to fix this and all of the requirements to be installed ?
EDIT:
If I try it to install in my global env, there is no problem. If I'm in virtualenv it first tries to collect something. It acts different ..
In python 3K, print is not a reserved keyword, but a built-in function, so you must use it like below:
print("Hello world!")
If you use print as a keyword, the interpreter will raise an exception:
SyntaxError: Missing parentheses in call to 'print'
You encounter such problem for installing a library, namely, pdfminer here, implemented in python 2 under python 3K environment. To solve this problem, you have 2 solutions:
Find the python 3K compatible version of the library.
Make a virtualenv using python 2 as the default interpreter.
So i guess that your pip is from python3? In that case there is no easy fix as the library is clearly not compatibile with python3, even the print in error is not going to work, and that is just top of the iceberg.
You will either have to:
Downgrade your app to python2
Find a different library that can do the same
Port the library to python3.
Porting library to python3 may not be as scary as you think, especially since it seems that someone started to work on that already but I have no way of verifying how mature is that, but it for sure is a start.

Python pip: cloudmonkey not installing correctly

I am trying to install Cloudmonkey on a VM. I downloaded cloudmonkey and tried to run the following command "pip install cloudmonkey" and get the following error:
Collecting cloudmonkey
Using cached cloudmonkey-5.3.2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "C:\Users[user]\AppData\Local\Temp\2\pip-build-gx5p5q5b\cloudmonkey\setup.py", line 50
print "If you're upgrading, run the following to enable parameter completion:"
^
SyntaxError: Missing parentheses in call to 'print'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users[user]\AppData\Local\Temp\2\pip-build
oudmonkey
Would someone be able to tell me what I am doing wrong with this install?
In source code, line 50 to 53 have four print statements without parenthesis in their setup.py. That is not compatible with python 3.x
It looks like from version 5.2 to 5.3, they added the print statements as upgrade notes. I recommend looking if there is an issue for compatibility, or you can download from source, remove those print statements, and then build/install.
Also, they have a docker image in github if you want to try that as well.
I just installed it using python 2.x and it was successful.

Syntax error while installing pdfminer using python

I want to use the pdfminer for extracting the text info. I have downloaded the pdfminer-20131113. I have installed the python in C:\python34.
Now using cmd, I am setting the path to the setup.py file of pdfminer.
and running the following command.
python setup.py install
But I am getting the below error.
> D:\pdfminer-20101226>python setup.py install
Traceback (most recent call last):
File "setup.py", line 3, in <module>
from pdfminer import __version__
File "D:\pdfminer-20101226\pdfminer\__init__.py", line 4
if __name__ == '__main__': print __version__
^
SyntaxError: invalid syntax
It seems to be some error in the setup.py file of pdfminer, which I am not sure how to resolve.
Also, I saw a pdf2txt.py file in the build folder of pdfminer. I tried to use that also as pdf2txt.py -o output.html pdffilename.pdf (with full path). but instead of converting it. it opens the pdf2txt.py file.
The PDFMiner project homepage states:
Written entirely in Python. (for version 2.4 or newer)
and further down:
Install Python 2.4 or newer. (Python 3 is not supported.)
so you'll have to install Python 2 to run this project.
Alternatively, you could try the Python 3 port, pdfminer3k; it hasn't seen any updates in 20 months, while PDFMiner does have more recent releases, so your mileage may vary.
This should solve your problem in Python 3
pip install pdfminer.six
pdfminer.six is a fork with Python 2+3 support using six. Last commit was 15 days ago.

Why are these Python scripts giving syntax errors? [duplicate]

This question already has answers here:
Invalid syntax (SyntaxError) in except handler when using comma
(5 answers)
What does "SyntaxError: Missing parentheses in call to 'print'" mean in Python?
(11 answers)
Closed last month.
I am trying to install python on windows, and this is my first day on python. Install goes well on windows 7 x64. But almost all scripts fails. I am trying to install celery and running following command on celery folder.
python setup.py build
and it fails, following is an error
File "setup.py", line 40
except ImportError, exc:
^
SyntaxError: invalid syntax
also following fails, which is valid print command i think.
>>> print 'a'
File "<stdin>", line 1
print 'a'
^
SyntaxError: invalid syntax
I am sure i am missing something here. Any idea what makes it fail?
Edit:
Below is summary of tasks i had to go through to get python working, made notes for myself but putting it here as well if it can help anyone
Install python and celery
=========================
-celery does not work with python3, so install latest python2
-install windows install for python2
-add C:\python2X to %PATH%
-set python path for lib
set PYTHONPATH=%PYTHONPATH%;c:\python2x
-install setuptools
http://pypi.python.org/pypi/setuptools
for x64 install does not work use
python setup.py install
-then can use easy_install
-now just use easy_install to install everything
A likely cause is version incompatibility, as Vincent Savard pointed out. Python 3 is not backwards compatible with Python 2
if print 1 doesn't work, but print(1) does, then you are running python 3, which seems to be the case
for Python 3 the syntax has been changed so
Change from except exc, var to except exc as var.
viz ( http://docs.python.org/release/3.1.3/whatsnew/3.0.html )
except ImportError, exc:
should be
except ImportError as exc:
Yeah you're probably running python 3. Try print("hello world")
If that works then you're running python 3

Categories

Resources