Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python unable to find lcm._lcm #299

Open
Tdogb opened this issue Nov 23, 2019 · 6 comments
Open

Python unable to find lcm._lcm #299

Tdogb opened this issue Nov 23, 2019 · 6 comments

Comments

@Tdogb
Copy link

Tdogb commented Nov 23, 2019

Using latest release version on Ubuntu 16.04

Python 3.5.2 (default, Oct  8 2019, 13:06:37) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lcm
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sa-zhao/Downloads/lcm-1.4.0/lcm-python/lcm/__init__.py", line 3, in <module>
    from ._lcm import LCM, LCMSubscription
ImportError: No module named 'lcm._lcm'
>>> 
@hoxell
Copy link
Contributor

hoxell commented Nov 23, 2019

Have you confirmed that cmake reported that all python paths were properly configured?

@contagon
Copy link

Did you ever find a solution to this? I'm getting the same error as well, Ubuntu 20.04.

@hoxell
Copy link
Contributor

hoxell commented Sep 20, 2020

I've tried to reproduce this on Ubuntu 18.04. CMake picked up the wrong python config (python 2.7 as executable but python3.6 libs), but that triggered different errors and could be fixed by setting the variables correctly. (python3 setup.py install, on the other hand, worked like a charm.)
The only way I managed to trigger the very same error was if I navigated to the lcm-python directory and tried to import lcm. Python would then try to import the local lcm folder instead of the installed lcm package. In that case __init__.py will raise the exception ('cause there's no _lcm in that folder/"package"). If that's not the case for you, could you provide some more info how to reproduce your issue?

@adrian-bodenmann
Copy link

I ran into the same error after installing LCM as described on https://lcm-proj.github.io/build_instructions.html, the reason being that it defaulted to installing for python (Python 2) but not for python3. As hoxovic indicated, setup.py has to be called from python3 install LCM for python3 as well, so after having installed LCM according to the instructions on https://lcm-proj.github.io/build_instructions.html do

cd ../lcm-python
sudo python3 setup.py install

It would be helpful to have a note regarding this in the instruction manual.

@Jelly123456
Copy link

when I run "sudo python3 setup.py install" command, I face the below error:

image

Anyone can help?

If I run "sudo python setup.py install", it can compile successfully, but I will have the same error as @Tdogb when importing lcm.

@adrian-bodenmann
Copy link

It looks like you are missing the Python header files.
You can install them by running sudo apt install python3-dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants