xcsp3team / pycsp3

A Python Library for modeling combinatorial constrained problems
https://www.pycsp.org
MIT License
61 stars 9 forks source link

Running `csp_single.py` fails #12

Closed cprudhom closed 4 years ago

cprudhom commented 4 years ago

I tried to run PyCSP3/pycsp3/problems/tests/cop_acad.py and got the following trace (and error):


|================================================================|
  Python: python3 (Python 3.7.1)
  Name: BoardColoration
  Data: [8,10]
  Name XML: BoardColoration-8-10.xml
|================================================================|
Command: python3 ./pycsp3/problems/cop/academic/BoardColoration.py -data=[8,10]
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/shutil.py", line 557, in move
    os.rename(src, real_dst)
FileNotFoundError: [Errno 2] No such file or directory: 'BoardColoration-8-10.xml' -> './pycsp3/problems/tests/tmp/cop/academic/PyCSP/BoardColoration-8-10.xml'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/kyzrsoze/Sources/PyCSP3/pycsp3/problems/tests/cop_acad.py", line 25, in <module>
    .add("WaterBucket", data="[8,5,3,4,4,0,8]")  # optimum 7
  File "/Users/kyzrsoze/Sources/PyCSP3/pycsp3/problems/tests/tester.py", line 40, in run
    xcsp.load(mode=2)
  File "/Users/kyzrsoze/Sources/PyCSP3/pycsp3/problems/tests/tester.py", line 218, in load
    shutil.move(self.name_xml, self.xml_path_py())
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/shutil.py", line 571, in move
    copy_function(src, real_dst)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/shutil.py", line 257, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/shutil.py", line 120, in copyfile
    with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: 'BoardColoration-8-10.xml'

PyCSP stderr : 
/Library/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python: can't open file './pycsp3/problems/cop/academic/BoardColoration.py': [Errno 2] No such file or directory

Process finished with exit code 1

Do you have any idea how I can fix that? In addition, I would appreciate if I could set the solver in __init__() of Tester.

Thank you

xcsp3team commented 4 years ago

This is fixed. Please, check that you can now run: python3 PyCSP3/pycsp3/problems/tests/cop_acad.py (I assume, when looking at your message that your first directory is PyCSP3)

The problem was that you needed to be in the root parent of pycsp3 to run the file. Now, you can run cop_acad.py from any directory

Note that these tests are for checking that the output of the compiler is still the same