4
votes

Hello I am trying to use Point Cloud Library in Python and as I am new to this C++ library and Python I am following the tutorial on http://strawlab.github.io/python-pcl/#pcl.PointCloud

However whenever I try to import pcl and define a module such as pcl.PointCloud() I get the following error;

AttributeError: 'module' object has no attribute 'PointCloud'

I have used sys.path.append to point to the correct directory where the PCL files have been installed as they are not in site packages. It says on the above link that the C++ code has already got Python bindings but I am unsure exactly what files I am trying to call in Python. Does anybody know how to overcome this error and load these modules?

Thanks, Andrew

4
How do you import pcl in Python? Show us the code. - user2737086
Can you please show how do you import pcl? - aIKid
I followed the example in the tutorial which the link is above, using the code import pcl then tried to called the PointCloud module using pcl.PointCloud() - Andrew McClune

4 Answers

1
votes

Try this,

sudo add-apt-repository ppa:sweptlaser/python3-pcl
sudo apt update
sudo apt install python3-pcl

After you've done that then you should be able to run:

python3 -c 'import pcl'

and it will return with no error (as opposed to ModuleNotFoundError: No module named 'pcl').

Tested on:

Ubuntu 18.04 LTS

Python 3.6.9

Reference: https://askubuntu.com/a/1170661/922137

0
votes

Try skipping the parentheses:

from pcl import PointCloud

And then create an instance of PointCloud, for example, p:

p = PointCloud()

Hope it helps!

0
votes

Looks like you need PCL 1.5.1 and cython 0.16 according to this page: http://strawlab.github.io/python-pcl/

0
votes

"""https://blog.pollithy.com/python/numpy/pointcloud/tutorial-pypcd"""

python3.6 -m pip install --user git+https://github.com/DanielPollithy/pypcd.git