potassco / clingo

🤔 A grounder and solver for logic programs.
https://potassco.org/clingo
MIT License
623 stars 82 forks source link

asprin.py:1:1-222:6: error: python support not available #68

Closed himanmookherjee closed 7 years ago

himanmookherjee commented 7 years ago

I was trying to run the examples in the encodings at https://sites.google.com/site/aspseqmining/ijcai-2016. Everyhting runs fine till the "maximal sequences" The error is thrown for the "preferences" example


*Error message asprin.py:1:1-222:6: error: python support not available ERROR: (clingo): fatal error ________ Python version in my machine [manati]s1779550: python Python 2.7.5 (default, Aug 2 2017, 11:05:32) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2 Type "help", "copyright", "credits" or "license" for more information.


OS: Scientific Linux


Version of clingo downloaded [manati]s1779550: ./clingo clingo version 5.2.1


Command line argument (as below) or while trying to run the command ./asprin 0 -c k=2 instance.lp frequent.lp preference.lp asprin.lib (from the URL https://sites.google.com/site/aspseqmining/ijcai-2016) [manati]s1779550: ./asprin asprin version 1.1.1 /afs/inf.ed.ac.uk/user/s17/s1779550/Documents/Himan/Kaj/UoEResearch/MScResearch_09OCT2017/IRDSProject_15OCT2017/Potassco/potassco-asp-executables/asprin.py:1:1-222:6: error: python support not available

*** ERROR: (clingo): fatal error

rkaminsk commented 7 years ago

Asprin requires clingo compiled with python support, which is not included in the Linux binaries we are providing online. You have to compile your own version. Note that clingo cannot be compiled with gcc 4.8. It requires at least gcc 4.9.

himanmookherjee commented 7 years ago

I am facing issues with the Clingo-withPython build for Linux.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ FATAL ERROR

Below are the details,

Clingo Source

[manati]s1779550: cd clingo-5.2.1 [manati]s1779550: ls -ltr total 46 -rw-r--r-- 1 s1779550 people 934 Aug 4 13:11 README.md -rw-r--r-- 1 s1779550 people 1080 Aug 4 13:11 LICENSE.md drwx------ 5 s1779550 people 2048 Aug 4 13:11 libreify drwx------ 2 s1779550 people 2048 Aug 4 13:11 libpyclingo drwx------ 2 s1779550 people 2048 Aug 4 13:11 libluaclingo drwx------ 6 s1779550 people 2048 Aug 4 13:11 libgringo drwx------ 5 s1779550 people 2048 Aug 4 13:11 libclingo -rw-r--r-- 1 s1779550 people 7312 Aug 4 13:11 INSTALL.md drwx------ 7 s1779550 people 2048 Aug 4 13:11 examples drwx------ 3 s1779550 people 2048 Aug 4 13:11 doc -rw-r--r-- 1 s1779550 people 6818 Aug 4 13:11 CMakeLists.txt drwx------ 2 s1779550 people 2048 Aug 4 13:11 cmake drwx------ 11 s1779550 people 2048 Aug 4 13:11 clasp -rw-r--r-- 1 s1779550 people 7990 Aug 4 13:11 CHANGES.md drwx------ 8 s1779550 people 2048 Aug 4 13:11 app

cmake version [manati]s1779550: ./cmake --version cmake version 3.10.0-rc3

Build attempts, messages and observations ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ FATAL ERROR + +

[manati]s1779550: /afs/inf.ed.ac.uk/user/s17/s1779550/Documents/Himan/Kaj/UoEResearch/MScResearch_09OCT2017/IRDSProject_15OCT2017/Potassco/clingo-gringo-clasp-aspirin/cmake-3.10.0-rc3-Linux-x86_64/bin/cmake -Hlibpyclingo -Bbuildhm -DCMAKE_BUILD_TYPE=Release -- The C compiler identification is GNU 4.8.5 -- The CXX compiler identification is GNU 4.8.5 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Warning (dev) in CMakeLists.txt: No cmake_minimum_required command is present. A line of code such as

cmake_minimum_required(VERSION 3.10)

should be added at the top of the file. The version specified may be lower if you wish to support older CMake versions for this project. For more information run "cmake --help-policy CMP0000". This warning is for project developers. Use -Wno-dev to suppress it.

-- Configuring done CMake Warning (dev) at CMakeLists.txt:17 (add_library): Policy CMP0028 is not set: Double colon in target name means ALIAS or IMPORTED target. Run "cmake --help-policy CMP0028" for policy details. Use the cmake_policy command to set the policy and suppress this warning.

Target "libpyclingo" links to target "Python::Python" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing? This warning is for project developers. Use -Wno-dev to suppress it.

-- Generating done -- Build files have been written to: /afs/inf.ed.ac.uk/user/s17/s1779550/Documents/Himan/Kaj/UoEResearch/MScResearch_09OCT2017/IRDSProject_15OCT2017/Potassco/clingo-gringo-clasp-aspirin/clingo-5.2.1/buildhm [manati]s1779550: /afs/inf.ed.ac.uk/user/s17/s1779550/Documents/Himan/Kaj/UoEResearch/MScResearch_09OCT2017/IRDSProject_15OCT2017/Potassco/clingo-gringo-clasp-aspirin/cmake-3.10.0-rc3-Linux-x86_64/bin/cmake --build buildhm/ Scanning dependencies of target libpyclingo [ 50%] Building CXX object CMakeFiles/libpyclingo.dir/pyclingo.o /afs/inf.ed.ac.uk/user/s17/s1779550/Documents/Himan/Kaj/UoEResearch/MScResearch_09OCT2017/IRDSProject_15OCT2017/Potassco/clingo-gringo-clasp-aspirin/clingo-5.2.1/libpyclingo/pyclingo.cc:32:20: fatal error: Python.h: No such file or directory

include

                ^

compilation terminated. gmake[2]: [CMakeFiles/libpyclingo.dir/pyclingo.o] Error 1 gmake[1]: [CMakeFiles/libpyclingo.dir/all] Error 2 gmake: *** [all] Error 2

rkaminsk commented 7 years ago

Hi, there are a couple of issues with the error messages above. Did you modify the CMakeLists.txt? It looks like there is no check for python and I am sure there is a minimum version check in clingo's CMakeLists.txt.

To compile with python support, the python development package has to be installed. Furthermore, you need at least gcc 4.9. The log shows that you have only gcc 4.8. I never used scientific linux but I think you can install centos' software collections, which make it easy to get up to date compilers. Here some links:

Of course, if you are not the admin of the system then things get more complicated. While it is certainly possible to compile everything yourself, it might be very involved if you never did this before. Then it probably better to install scientific linux in a virtualbox and install the necessary packages there and then compile clingo.

I can also do this for you but I would need to know exactly which scientific linux you are using and exactly which python version you have installed. You should be able to figure this out using uname and yum. The list and info commands of the the latter can be used to list installed packages and get information about specific packages, respectively.

himanmookherjee commented 7 years ago

Hello Rolland ( Correct me if I am wrong)!

Yes, this is the first time I am doing this and I am not the Admin. Currently, this is a University of Edinburgh managed computer. I would have loved to do this myself to learn and would do that by December, when I would have more time after the semester. But I would first like to use the ASP framework for a quick project and then for my PhD research. I barely have couple days to finish the quick project. So, it would be immensely helpful if you can help with a pre-compiled binary for Scientific Linux.

Following are the information you said you need,

[manati]s1779550: uname -r 3.10.0-693.2.2.el7.x86_64

[manati]s1779550: uname -a Linux manati.inf.ed.ac.uk 3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 12 10:10:26 CDT 2017 x86_64 x86_64 x86_64 GNU/Linux

[manati]s1779550: lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch Distributor ID: Scientific Description: Scientific Linux release 7.3 (Nitrogen) Release: 7.3 Codename: Nitrogen

[manati]s1779550: cat /etc/*release NAME="Scientific Linux" VERSION="7.3 (Nitrogen)" ID="rhel" ID_LIKE="fedora" VERSION_ID="7.3" PRETTY_NAME="Scientific Linux 7.3 (Nitrogen)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:scientificlinux:scientificlinux:7.3:GA" HOME_URL="http://www.scientificlinux.org//" BUG_REPORT_URL="mailto:scientific-linux-devel@listserv.fnal.gov" REDHAT_BUGZILLA_PRODUCT="Scientific Linux 7" REDHAT_BUGZILLA_PRODUCT_VERSION=7.3 REDHAT_SUPPORT_PRODUCT="Scientific Linux" REDHAT_SUPPORT_PRODUCT_VERSION="7.3" Scientific Linux release 7.3 (Nitrogen) Scientific Linux release 7.3 (Nitrogen) Scientific Linux release 7.3 (Nitrogen)

[manati]s1779550: yum list > yum-list-clingoslinuxcompileissue.txt Attached file, yum-list-clingoslinuxcompileissue.txt

[manati]s1779550: yum info > yum-info-clingoslinuxcompileissue.txt Attached file, yum-info-clingoslinuxcompileissue.txt

yum-info-clingoslinuxcompileissue.txt yum-list-clingoslinuxcompileissue.txt

Feel free to let me know of anything else I can help with.

Last but not the least, many many thanks for your very prompt help. We are looking forward to use the Potassco framework for an involved longer Term project. Cheers! Himan

yum-info-clingoslinuxcompileissue.txt yum-list-clingoslinuxcompileissue.txt

javier-romero commented 7 years ago

Dear Himan,

One more thing to take into account is that the experiments of that paper were run using asprin-1, which runs with clingo-4.5 (with python support). I think they will not work with clingo-5 because of some tiny details.

Recently I released asprin-3 (https://github.com/potassco/asprin) but unfortunately the input syntax has changed a bit, and the experiments of the paper will not work with it. I am planning to update the encodings of the paper to asprin-3 soon, but I haven't done it yet.

Cheers, Javier

himanmookherjee commented 7 years ago

That should be ok for me. I can use clingo-4.5 for now.

javier-romero commented 7 years ago

Dear Himan,

I've changed the preference.lp file, so that if you want now you can use asprin-3 (which is much more stable than asprin-1) with clingo-5.2.1.

Note that now you do not have to add the file asprin.lib

This is the output I get: $ cat preference.lp

preference(p1,more(cardinality)){

pos(X) & cover(T) : slot(X), seq(T,1,E) }.

preference(p2,aconf){ hasfreq(F) : freq(F);

                  cover(T) : seq(T,1,E) }.

preference(p3,pareto){ p1; p2 }.

optimize(p3).

cont(E,F) :- item(E), F = #count{ T : seq(T,P,E) }. freq(1..M) :- M = #max{ F : cont(E,F) }.

hasfreq(F) :- cont(E,F), pat(X,E). hasfreq(F-1) :- hasfreq(F), 1 < F.

program preference(aconf).

better(P) :- preference(P,aconf),

sum{ 1,F,T : holds'(atom(hasfreq(F))),

             holds (atom(cover(T)));
    -1,F,T : holds (atom(hasfreq(F))),
             holds'(atom(cover(T))) } > 0.

bettereq(P) :- preference(P,aconf),

sum{ 1,F,T : holds'(atom(hasfreq(F))),

               holds (atom(cover(T)));
      -1,F,T : holds (atom(hasfreq(F))),
               holds'(atom(cover(T))) } >= 0.

$ asprin 0 -c k=2 instance.lp frequent.lp preference.lp asprin version 3.0.2 Reading from instance.lp ... Solving... Answer: 1 pat(1,a) Answer: 2 pat(1,c) OPTIMUM FOUND Answer: 3 pat(1,b) OPTIMUM FOUND Answer: 4 pat(2,b) pat(1,c) Answer: 5 pat(2,a) pat(1,c) OPTIMUM FOUND Answer: 6 pat(2,a) pat(1,b) OPTIMUM FOUND Answer: 7 pat(3,a) pat(2,b) pat(1,c) OPTIMUM FOUND Answer: 8 pat(1,a) OPTIMUM FOUND Answer: 9 pat(2,b) pat(1,c) OPTIMUM FOUND

Models : 9 Optimum : yes Optimal : 7 preference.lp.txt

I hope everything runs smoothly now.

Cheers, Javier

rkaminsk commented 7 years ago

Hi, check the following binaries. I compiled them on SL 7.4 and they even run on our Debian machines. If you want to do this yourself, here is what I did:

# get scl repository from centos
wget http://mirror.centos.org/centos/7/extras/x86_64/Packages/centos-release-scl-2-2.el7.centos.noarch.rpm
wget http://mirror.centos.org/centos/7/extras/x86_64/Packages/centos-release-scl-rh-2-2.el7.centos.noarch.rpm
yum install centos-release-scl-2-2.el7.centos.noarch.rpm centos-release-scl-rh-2-2.el7.centos.noarch.rpm

# add epel repository
yum install yum-conf-epel

# install clingo dependencies
yum update
yum install devtoolset-7-gcc-c++ llvm-toolset-7-cmake scons re2c python-devel

When building clingo make sure to link statically against the clingo and gcc libraries and don't forget to enable the scls:

scl enable devtoolset-7 llvm-toolset-7 bash
himanmookherjee commented 7 years ago

Thank you much for all the help. I guess I am still facing the last bit of issues, after which it all works! - I have a gut feel that I am close, close with all your help.

Now, I have added the clingo Linux binary (shared by ROLLAND), the recent version of aspirin from the Potassco Github, the preference.lp file (fronJavier's posted suggestion above) and all other possible dependencies I could have thought of in the same folder.

I am running to test the following "preference" code (the recent one), [manati]s1779550: ./asprin.py 0 -c k=2 instance.lp frequent.lp preference.lp

But gettiing the following error, [manati]s1779550: ./asprin.py 0 -c k=2 instance.lp frequent.lp preference.lp Traceback (most recent call last): File "./asprin.py", line 26, in import src.main.main File "/afs/inf.ed.ac.uk/user/s17/s1779550/Documents/Himan/Kaj/UoEResearch/MScResearch_09OCT2017/IRDSProject_15OCT2017/Potassco/potassco-asp-executables/src/main/main.py", line 34, in import clingo ImportError: No module named clingo

Below is a list of codes and data files in the folder from which I am running the above command, [manati]s1779550: ls -ltr total 16895 -rwxr-xr-x 1 s1779550 people 1420736 Aug 4 12:37 lpconvert -rwxr-xr-x 1 s1779550 people 1380296 Aug 4 12:37 reify -rwxr-xr-x 1 s1779550 people 2712928 Aug 4 12:38 clasp -rwxr-xr-x 1 s1779550 people 5263256 Aug 4 12:38 gringo -rwxrwxrwx 1 s1779550 people 1572 Oct 11 18:15 setup.py -rwxrwxrwx 1 s1779550 people 3916 Oct 11 18:15 README.md -rwxrwxrwx 1 s1779550 people 132 Oct 11 18:15 MANIFEST.in -rwxrwxrwx 1 s1779550 people 1070 Oct 11 18:15 LICENSE.txt drwxrwxrwx 4 s1779550 people 2048 Oct 11 18:15 asprin -rw-r--r-- 1 s1779550 people 433 Oct 29 15:06 frequent.lp -rw-r--r-- 1 s1779550 people 216 Oct 29 15:06 instance.lp -rw-r--r-- 1 s1779550 people 417 Oct 29 15:10 closed.lp -rw-r--r-- 1 s1779550 people 332 Oct 29 15:12 maximal.lp -rwxr-xr-x 1 s1779550 people 6446072 Nov 1 12:10 clingo -rw-r--r-- 1 s1779550 people 867 Nov 1 15:29 preference.lp -rwxr-xr-x 1 s1779550 people 1405 Nov 1 15:47 init.py -rwxr-xr-x 1 s1779550 people 1325 Nov 1 15:47 asprin.py -rwxr-xr-x 1 s1779550 people 53119 Nov 1 15:47 asprin_lib.lp drwxrwxrwx 8 s1779550 people 2048 Nov 1 15:50 src

Once again, the "clingo" is the Scientific Linux binary, preference.lp is the recent one downloaded from Javier's note above, aspirin.py is the recent version of the aspirin from the Potassco Github.

Lemme know - am I missing anything?

Thanks in advance. Himan

rkaminsk commented 7 years ago

Hi, I did not know that asprin is using the clingo python module because I just uploaded clingo binaries. Here is also the clingo python module. You have to extract it somewhere and point the PYTHONPATH environment variable to its location.

himanmookherjee commented 7 years ago

Thanks. Where would I find the PYTHONPATH var?

rkaminsk commented 7 years ago

Where would I find the PYTHONPATH var?

You have two options here. Put clingo.so somewhere where python will find it, e.g., your user site:

mkdir -p ~/.local/lib/python2.7/site-packages
cp clingo.so ~/.local/lib/python2.7/site-packages

Or before running asprin set the PYTHONPATH environment variable:

export PYTHONPATH=<path to folder containing clingo.so>
himanmookherjee commented 7 years ago

Thanks a ton, Rolland and Javier. The "Preferences encoding" works now in my Machine and system. I am glad that I can use the ASP framework for my project(s). Cheers! Himan

rkaminsk commented 7 years ago

Great it worked out! Closing the issue then.