First time here? Checkout the FAQ!
x
0 votes
by (260 points)
Hi,

I am running to a carputils import error when I am trying to run the python script for the reentry protocol example (example 21). The error I am running into is

Traceback (most recent call last):
  File "/home/silvalab/.local/lib/python3.8/site-packages/bin/tuneCV", line 8, in <module>
    from carputils import tools
ImportError: No module named carputils
Traceback (most recent call last):
  File "run.py", line 730, in <module>
    run()
  File "/home/silvalab/.local/lib/python3.8/site-packages/carputils/tools.py", line 524, in wrapped
    ret = run(args, job)
  File "run.py", line 456, in run
    converge_CV(args,job)
  File "run.py", line 657, in converge_CV
    job.bash(cmd)
  File "/home/silvalab/.local/lib/python3.8/site-packages/carputils/job/job.py", line 242, in bash
    self.register(ShellCommand(cmd, message), *args, **kwargs)
  File "/home/silvalab/.local/lib/python3.8/site-packages/carputils/job/job.py", line 119, in register
    self._queue.pop(0).execute()
  File "/home/silvalab/.local/lib/python3.8/site-packages/carputils/job/command.py", line 163, in execute
    divertoutput.call(self._cmd, stdout=self._stdout, stderr=self._stderr)
  File "/home/silvalab/.local/lib/python3.8/site-packages/carputils/divertoutput.py", line 43, in wrapped
    return func(cmd, *args, **kwargs)
  File "/home/silvalab/.local/lib/python3.8/site-packages/carputils/divertoutput.py", line 147, in call
    raise subprocess.CalledProcessError(proc.returncode, cmd[0])
subprocess.CalledProcessError: Command '/home/silvalab/.local/lib/python3.8/site-packages/bin/tuneCV' returned non-zero exit status 1.

Please let me know if you have ideas on how to fix this error. It is not letting me run/calculate anything for this example. Thanks for the help in advance.

Best,

Sushruth
by (17.6k points)
Seems that your PYTHONPATH is not set correctly. What's the output of

python -c "import sys; print(sys.path)"

?
by (260 points)
Here's the output:
python -c "import sys; print(sys.path)"
['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages']

This is because I also have Python 2 installed, this gives the Python 2 path. Calling Python 3:

python3 -c "import sys; print(sys.path)"
['', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/silvalab/.local/lib/python3.8/site-packages', '/usr/local/lib/python3.8/dist-packages', '/usr/lib/python3/dist-packages']

1 Answer

0 votes
by (17.6k points)
by (260 points)
I added the two lines:
export PATH=$PATH:$HOME/openCARP/external/carputils/bin
export PYTHONPATH=$PYTHONPATH:$HOME/openCARP/external/carputils

Now when I run python -c "import sys; print(sys.path)":
['', '/home/silvalab/Desktop/openCARP/tutorials/02_EP_tissue/21_reentry_induction', '/home/silvalab/Desktop/openCARP/external/carputils', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages']

When I try to run example 21 "reentry induction", I am receiving a different error:
Traceback (most recent call last):
  File "/home/silvalab/Desktop/openCARP/external/carputils/bin/tuneCV", line 8, in <module>
    from carputils import tools
  File "/home/silvalab/Desktop/openCARP/external/carputils/carputils/tools.py", line 29, in <module>
    from pathlib import Path
ImportError: No module named pathlib
Traceback (most recent call last):
  File "run.py", line 730, in <module>
    run()
  File "/home/silvalab/Desktop/openCARP/external/carputils/carputils/tools.py", line 524, in wrapped
    ret = run(args, job)
  File "run.py", line 456, in run
    converge_CV(args,job)
  File "run.py", line 657, in converge_CV
    job.bash(cmd)
  File "/home/silvalab/Desktop/openCARP/external/carputils/carputils/job/job.py", line 242, in bash
    self.register(ShellCommand(cmd, message), *args, **kwargs)
  File "/home/silvalab/Desktop/openCARP/external/carputils/carputils/job/job.py", line 119, in register
    self._queue.pop(0).execute()
  File "/home/silvalab/Desktop/openCARP/external/carputils/carputils/job/command.py", line 163, in execute
    divertoutput.call(self._cmd, stdout=self._stdout, stderr=self._stderr)
  File "/home/silvalab/Desktop/openCARP/external/carputils/carputils/divertoutput.py", line 43, in wrapped
    return func(cmd, *args, **kwargs)
  File "/home/silvalab/Desktop/openCARP/external/carputils/carputils/divertoutput.py", line 147, in call
    raise subprocess.CalledProcessError(proc.returncode, cmd[0])
subprocess.CalledProcessError: Command '/home/silvalab/Desktop/openCARP/external/carputils/bin/tuneCV' returned non-zero exit status 1.

Let me know what you think!

Sushruth
by (17.6k points)
There seems to be something wrong with your local python installation. pathlib is part of the python standard library: https://docs.python.org/3.8/library/pathlib.html
Welcome to openCARP Q&A. Ask questions and receive answers from other members of the community. For best support, please use appropriate TAGS!
architecture, carputils, documentation, experiments, installation-containers-packages, limpet, slimfem, website, governance
...