Unexpected keyword argument 'text' for Python3.1
Anette-Hunziker opened this issue · comments
Running parzu_server.py with python3.1 I get the following error.
2022-04-20T08:32:54.677401533Z File "parzu_server.py", line 64, in __init__
2022-04-20T08:32:54.677406805Z self.parser = Parser(options, timeout=timeout)
2022-04-20T08:32:54.677411401Z File "/ParZu/parzu_class.py", line 261, in __init__
2022-04-20T08:32:54.677416572Z swipl_version, _ = Popen(['swipl', '--version'], stdout=PIPE, text=True).communicate()
2022-04-20T08:32:54.677423357Z TypeError: __init__() got an unexpected keyword argument 'text'
2022-04-20T08:32:55.025972638Z self.prolog_preprocess.close()
2022-04-20T08:32:55.026000012Z AttributeError: 'Parser' object has no attribute 'prolog_preprocess'
I believe this to be related to https://stackoverflow.com/questions/52663518/python-subprocess-popen-doesnt-take-text-argument
To run the code, I used the following Dockerfile
RUN apt-get update && apt-get -y install software-properties-common && add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install \
git \
swi-prolog \
sfst \
unzip \
wget \
python3.1 \
python3-pexpect \
python3-flask
ADD https://api.github.com/repos/rsennrich/ParZu/git/refs/heads/master version.json
RUN git clone https://github.com/rsennrich/ParZu
RUN (cd ParZu; bash install.sh)
RUN apt-get update && apt-get -y install curl
EXPOSE 5003
WORKDIR /ParZu
CMD python3 parzu_server.py --host 0.0.0.0
To circumvent this error, I also tried using python3.7. However, this causes the server to respond with an empty list on the first request, with subsequent requests working fine.
This can be reproduced with the following Dockerfile
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install \
git \
swi-prolog \
sfst \
unzip \
wget \
python3.1 \
python3-pexpect \
python3-flask
ADD https://api.github.com/repos/rsennrich/ParZu/git/refs/heads/master version.json
RUN git clone https://github.com/rsennrich/ParZu
RUN (cd ParZu; bash install.sh)
RUN apt-get update && apt-get -y install curl
EXPOSE 5003
WORKDIR /ParZu
CMD python3 parzu_server.py --host 0.0.0.0
Thank you for your help!
thanks for reporting this.
With a recent commit (bdc466d), it is indeed true that Python 3.7 is now required. I updated the documentation and Dockerfile.
The problem you observed with 3.7 is related to a different behaviour of swipl in Docker (specifically, prompts being suppressed). While I didn't quite get to the root of this difference, I updated parzu_class.py to resolve this issue of the first query returning an empty output.