symforce-org / symforce

Fast symbolic computation, code generation, and nonlinear optimization for robotics
https://symforce.org
Apache License 2.0
1.44k stars 147 forks source link

No module named 'sym' when installing with cmake #349

Closed arbor-arthur closed 1 year ago

arbor-arthur commented 1 year ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Git clone v0.9.0 of symforce.

mkdir build
cd build
cmake ..
make -j $(nproc)
sudo make install
export PYTHONPATH="$PYTHONPATH:/path/to/symforce:/path/to/symforce/build/lcmtypes/python2.7"

python3 -c "import symforce; print(symforce.get_symbolic_api())"
symengine

python3 -c "from symforce import cc_sym"

python3 -c "import symforce.symbolic as sf"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/symforce/symforce/symbolic.py", line 30, in <module>
    from symforce.geo import *
  File "/opt/symforce/symforce/geo/__init__.py", line 18, in <module>
    from . import unsupported
  File "/opt/symforce/symforce/geo/unsupported/__init__.py", line 10, in <module>
    from .pose2_se2 import Pose2_SE2
  File "/opt/symforce/symforce/geo/unsupported/pose2_se2.py", line 10, in <module>
    from symforce.ops.interfaces.lie_group import LieGroup
  File "/opt/symforce/symforce/ops/__init__.py", line 75, in <module>
    import sym
ModuleNotFoundError: No module named 'sym'

Expected behavior I should get no error when importing symforce.symbolic

Environment (please complete the following information):

Additional context My workaround is to use pip install symforce for code generation, and only using cmake install for c++ libraries and linking.

aaron-skydio commented 1 year ago

Did you pip install -r dev_requirements.txt first? That should install sym

arbor-arthur commented 1 year ago

Which pip package in dev_requirements.txt provides sym? I don't see a package named sym listed there? I thought the sym package was an internal module exposing the C++ part of symforce.

I tried installing the public pip sym package, but that seemed like an entirely different package than the one used here. It didn't have a Rot2 or other Lie group types for example.

I also tried pip install -r dev_requirements.txt and then had some other errors come up. I probably could have avoided those by using a virtual environment, but I wanted to install symforce system-wide.

aaron-skydio commented 1 year ago

These lines: https://github.com/symforce-org/symforce/blob/84f76b601ea6575fb990a9c23f7b77611911eab7/dev_requirements.txt#L327-L328

The sym python package is pure-python, and is the same as the symforce-sym package on PyPI, you could install it from PyPI instead if you aren't modifying it. It's the generated python numerical geometry and camera types

aaron-skydio commented 1 year ago

I tried installing the public pip sym package, but that seemed like an entirely different package than the one used here. It didn't have a Rot2 or other Lie group types for example.

If you tried installing this package, that's not ours - this one should be what you want

aaron-skydio commented 1 year ago

I also tried pip install -r dev_requirements.txt and then had some other errors come up. I probably could have avoided those by using a virtual environment, but I wanted to install symforce system-wide.

This is a good point, we should have a way to install the minimal unpinned dependencies required for a from-source build for use cases like this. It's really unfortunate that pip doesn't have a way to install just the dependencies of a package, but it doesn't