pytsp icon indicating copy to clipboard operation
pytsp copied to clipboard

concorde not found on path, permissions issue?

Open lquesada030375 opened this issue 9 years ago • 3 comments

Dear Matt,

Thanks for you prompt answer. Now compilation went fine, but I am getting this error when running test_concorde.py:

4c244:tests lquesada$ python test_concorde.py Traceback (most recent call last): File "test_concorde.py", line 1, in import pytest ImportError: No module named pytest

Cheers, Luis

lquesada030375 avatar Dec 03 '15 14:12 lquesada030375

The previous one was not really an issue, but this one is: pyconcorde is telling me that concorde is not in my path. But as you can see below it is since I can call it directly.

4c244:pyconcorde-master lquesada$ py.test ======================================== test session starts ======================================== platform darwin -- Python 2.7.10, pytest-2.8.3, py-1.4.31, pluggy-0.3.1 rootdir: /Users/lquesada/Downloads/pyconcorde-master, inifile: collected 0 items / 1 errors

============================================== ERRORS =============================================== ______________________________ ERROR collecting tests/test_concorde.py ______________________________ tests/test_concorde.py:4: in from pyconcorde import atsp_tsp, run_concorde, dumps_matrix pyconcorde/init.py:17: in raise ValueError("Cannot fine the concorde executable;" E ValueError: Cannot fine the concorde executable; add to your PATH or specify with CONCORDE env var ====================================== 1 error in 0.12 seconds ====================================== 4c244:pyconcorde-master lquesada$ concorde ~/Downloads/d493.tsp concorde /Users/lquesada/Downloads/d493.tsp Host: 4c244 Current process id: 39910 Using random seed 1449155243 Problem Name: d493 Drilling problem (Reinelt) Problem Type: TSP Number of Nodes: 493

More over if I set the env var directly it I can go a bit further but face another issue:

4c244:pyconcorde-master lquesada$ py.test ======================================== test session starts ======================================== platform darwin -- Python 2.7.10, pytest-2.8.3, py-1.4.31, pluggy-0.3.1 rootdir: /Users/lquesada/Downloads/pyconcorde-master, inifile: collected 1 items

tests/test_concorde.py F

============================================= FAILURES ============================================== _____________________________________________ test_tour _____________________________________________

matrix = [[0, 791051, 786792, 87405, 839957, 52060, ...], [792333, 0, 41769, 735958, 129216, 741642, ...], [788130, 41769, 0, 7...62, 38822, ...], [842007, 129700, 163828, 785633, 0, 791316, ...], [52105, 741466, 737208, 38942, 790373, 0, ...], ...]

def test_tour(matrix):
    matrix_sym = atsp_tsp(matrix, strategy="avg")
    outf = "/tmp/myroute.tsp"
    with open(outf, 'w') as dest:
        dest.write(dumps_matrix(matrix_sym, name="My Route"))
  tour = run_concorde(outf, start=10)

/Users/lquesada/Downloads/pyconcorde-master/tests/test_concorde.py:19:


/Users/lquesada/Downloads/pyconcorde-master/pyconcorde/init.py:73: in run_concorde output = subprocess.check_output([CONCORDE, tsp_path], shell=False) /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py:566: in check_output process = Popen(stdout=PIPE, _popenargs, *_kwargs) /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py:710: in init errread, errwrite)


self = <subprocess.Popen object at 0x10d776dd0> args = ['/Users/lquesada/concorde/concorde/TSP/', '/tmp/myroute.tsp'] executable = '/Users/lquesada/concorde/concorde/TSP/', preexec_fn = None, close_fds = False cwd = None, env = None, universal_newlines = False, startupinfo = None, creationflags = 0 shell = False, to_close = set([9]), p2cread = None, p2cwrite = None, c2pread = 9, c2pwrite = 11 errread = None, errwrite = None

def _execute_child(self, args, executable, preexec_fn, close_fds,
                   cwd, env, universal_newlines,
                   startupinfo, creationflags, shell, to_close,
                   p2cread, p2cwrite,
                   c2pread, c2pwrite,
                   errread, errwrite):
    """Execute program (POSIX version)"""

    if isinstance(args, types.StringTypes):
        args = [args]
    else:
        args = list(args)

    if shell:
        args = ["/bin/sh", "-c"] + args
        if executable:
            args[0] = executable

    if executable is None:
        executable = args[0]

    def _close_in_parent(fd):
        os.close(fd)
        to_close.remove(fd)

    # For transferring possible exec failure from child to parent
    # The first char specifies the exception type: 0 means
    # OSError, 1 means some other error.
    errpipe_read, errpipe_write = self.pipe_cloexec()
    try:
        try:
            gc_was_enabled = gc.isenabled()
            # Disable gc to avoid bug where gc -> file_dealloc ->
            # write to stderr -> hang.  http://bugs.python.org/issue1336
            gc.disable()
            try:
                self.pid = os.fork()
            except:
                if gc_was_enabled:
                    gc.enable()
                raise
            self._child_created = True
            if self.pid == 0:
                # Child
                try:
                    # Close parent's pipe ends
                    if p2cwrite is not None:
                        os.close(p2cwrite)
                    if c2pread is not None:
                        os.close(c2pread)
                    if errread is not None:
                        os.close(errread)
                    os.close(errpipe_read)

                    # When duping fds, if there arises a situation
                    # where one of the fds is either 0, 1 or 2, it
                    # is possible that it is overwritten (#12607).
                    if c2pwrite == 0:
                        c2pwrite = os.dup(c2pwrite)
                    if errwrite == 0 or errwrite == 1:
                        errwrite = os.dup(errwrite)

                    # Dup fds for child
                    def _dup2(a, b):
                        # dup2() removes the CLOEXEC flag but
                        # we must do it ourselves if dup2()
                        # would be a no-op (issue #10806).
                        if a == b:
                            self._set_cloexec_flag(a, False)
                        elif a is not None:
                            os.dup2(a, b)
                    _dup2(p2cread, 0)
                    _dup2(c2pwrite, 1)
                    _dup2(errwrite, 2)

                    # Close pipe fds.  Make sure we don't close the
                    # same fd more than once, or standard fds.
                    closed = { None }
                    for fd in [p2cread, c2pwrite, errwrite]:
                        if fd not in closed and fd > 2:
                            os.close(fd)
                            closed.add(fd)

                    if cwd is not None:
                        os.chdir(cwd)

                    if preexec_fn:
                        preexec_fn()

                    # Close all other fds, if asked for - after
                    # preexec_fn(), which may open FDs.
                    if close_fds:
                        self._close_fds(but=errpipe_write)

                    if env is None:
                        os.execvp(executable, args)
                    else:
                        os.execvpe(executable, args, env)

                except:
                    exc_type, exc_value, tb = sys.exc_info()
                    # Save the traceback and attach it to the exception object
                    exc_lines = traceback.format_exception(exc_type,
                                                           exc_value,
                                                           tb)
                    exc_value.child_traceback = ''.join(exc_lines)
                    os.write(errpipe_write, pickle.dumps(exc_value))

                # This exitcode won't be reported to applications, so it
                # really doesn't matter what we return.
                os._exit(255)

            # Parent
            if gc_was_enabled:
                gc.enable()
        finally:
            # be sure the FD is closed no matter what
            os.close(errpipe_write)

        # Wait for exec to fail or succeed; possibly raising exception
        # Exception limited to 1M
        data = _eintr_retry_call(os.read, errpipe_read, 1048576)
    finally:
        if p2cread is not None and p2cwrite is not None:
            _close_in_parent(p2cread)
        if c2pwrite is not None and c2pread is not None:
            _close_in_parent(c2pwrite)
        if errwrite is not None and errread is not None:
            _close_in_parent(errwrite)

        # be sure the FD is closed no matter what
        os.close(errpipe_read)

    if data != "":
        try:
            _eintr_retry_call(os.waitpid, self.pid, 0)
        except OSError as e:
            if e.errno != errno.ECHILD:
                raise
        child_exception = pickle.loads(data)
      raise child_exception

E OSError: [Errno 13] Permission denied

/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py:1335: OSError ===================================== 1 failed in 0.31 seconds ====================================== 4c244:pyconcorde-master lquesada$

lquesada030375 avatar Dec 03 '15 15:12 lquesada030375

What are the permissions on you concorde executable? ls -alth concorde

perrygeo avatar Dec 22 '15 13:12 perrygeo

i got the same problem

Anubisxcw avatar Mar 29 '23 03:03 Anubisxcw