0

I am running this repo: https://github.com/TUMFTM/global_racetrajectory_optimization on a WSL (alternatively I have tried it on multiple different machines like several Linux machines as well as an NVIDIA Jetson Orin Nano devkit).

But somehow, as I try to run the main script I am receiving an import error like below:

Traceback (most recent call last):
  File "main_globaltraj.py", line 1, in <module>
    import opt_mintime_traj
  File "/home/user/Raceline-Optimization/opt_mintime_traj/__init__.py", line 1, in <module>
    import opt_mintime_traj.src
  File "/home/user/Raceline-Optimization/opt_mintime_traj/src/__init__.py", line 1, in <module>
    import opt_mintime_traj.src.opt_mintime
  File "/home/user/Raceline-Optimization/opt_mintime_traj/src/opt_mintime.py", line 7, in <module>
    import trajectory_planning_helpers as tph
  File "/home/user/.local/lib/python3.7/site-packages/trajectory_planning_helpers/__init__.py", line 23, in <module>
    import trajectory_planning_helpers.opt_min_curv
  File "/home/user/.local/lib/python3.7/site-packages/trajectory_planning_helpers/opt_min_curv.py", line 3, in <module>
    import quadprog
ImportError: /home/user/.local/lib/python3.7/site-packages/quadprog.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _Z7qpgen2_PdS_PiS0_S_S_S_S_S_S0_S0_S0_S0_S0_S0_S_S0_

I followed all the steps as required, and the required packages I have, the environment I run the code on are the same as what's described inthe README and requirements.txt. I have tried different versions of required packages (e.g. most up-to-date ones, previous ones etc.), but that didn't solve the problem either. I tried isolating my environment by using Docker, Conda and python's venv. Clearly, there's a compatibility issue and I am unable to resolve it myself. I would highly appreciate it if someone could help me. Thanks!

Tim Roberts
  • 48,973
  • 4
  • 21
  • 30
bach
  • 1
  • 2
  • Did you `apt install python3-dev`? It looks like the `quadprog` module is looking for something in a C library that isn't there. – Tim Roberts Aug 13 '23 at 18:43
  • 1
    Make sure in particular that your quadprog-the-Python-library and quadprog-the-C++-library releases are built against each other; a serious version mismatch (or using a compiler with a different ABI convention between the two, but that's not as likely on Linux as it is on Windows) would explain this. – Charles Duffy Aug 13 '23 at 18:55
  • @TimRoberts Yes, I did install python3-dev – bach Aug 13 '23 at 18:57
  • (I don't see how not installing python3-dev would cause this, btw; that would be a header-not-found problem, not a symbol-not-found problem) – Charles Duffy Aug 13 '23 at 18:57
  • @CharlesDuffy If you don't mind, can you elaborate on that? I am relatively new to the community. Thus, there's a huge gap in fundamentals. – bach Aug 13 '23 at 18:58
  • @CharlesDuffy I agree, but the documentation at that github site makes that exact suggestion to get `quadprog`. – Tim Roberts Aug 13 '23 at 18:58
  • 1
    ...huh. I wonder if this is a nonstandard C compiler. Reading https://github.com/quadprog/quadprog/blob/master/quadprog/solve.QP.c, it's definitely C, but it's absolutely not a standard C name for the symbol. And if you used a less-standard C compiler for the Python bindings and something more standard for quadprog itself, that would fit... – Charles Duffy Aug 13 '23 at 19:05
  • ...anyhow, the details aren't important. The important thing is that you need to compile the Python bindings and the underlying library with the same compiler, and the same version of their dependencies. If one of them is a binary you compiled somewhere else, f/e, then build that component from source instead on a system identical to the one you're deploying to (same Linux distro, same Python packaging, etc). – Charles Duffy Aug 13 '23 at 19:07
  • Right. I even tried to compile the quadprog from source, but somehow one of the required files quadprog.c is not in the repo. I even posted it in the issues section, no reply yet. It also surprises me that nobody posted anything about it yet. – bach Aug 13 '23 at 19:10
  • 1
    Ah. If you're using binaries that the maintainer built on who-knows-what distro release, with who-knows-what compiler, then this kind of thing is a lot less surprising. – Charles Duffy Aug 13 '23 at 19:12

1 Answers1

0

All the packages and environment I was able to run the code on. So, I was able to resolve the issue by setting my environment in this random way (see the screenshot above in the hyperlink). Somehow, this combination worked out just well. I also realized that the quadprog repo doesn't really have 0.1.7 on their github page even though I was able to install the prebuilt one using pip. So I downloaded the quadprog with a specific tag 0.1.8 (oldest) and installed it from source; magically it worked unlike my previous tries. But it kept giving me the import error, so I pip installed the most recent quadprog. I also manually changed requirements.txt to address all this change (e.g., edited quadprog==0.1.7 as quadprog>=0.1.7 and so on).

bach
  • 1
  • 2