strawlab / python-pcl

Python bindings to the pointcloud library (pcl)
http://strawlab.github.com/python-pcl/
Other
2.01k stars 700 forks source link

Issue on pcl_visualization #127

Open HaroldMurcia opened 7 years ago

HaroldMurcia commented 7 years ago

Hi everyone,

I'm following the example: visualization.py. My python works the line: import pcl. However, it does not run the line: import pcl.pcl_visualization File "", line 1, in ImportError: No module named pcl_visualization

How can I solve?

EsrtG commented 7 years ago

Have you tried this one : import pcl from pcl import pcl_visualization

HaroldMurcia commented 7 years ago

Hi EstG; Yes; but it doesn't work.

Traceback (most recent call last): File "", line 1, in from pcl import pcl_visualization ImportError: cannot import name pcl_visualization

Sirokujira commented 7 years ago

Currently, visualization is checking the operation It is only under Windows environment.

It can not operate under MacOS / Ubuntu environment. (as the reason, Under Windows environment, by installing all-in-one package Although it can be adjusted to a certain VTK version, In MacOS / Ubuntu environment, the version of VTK may change)

saibash commented 7 years ago

I can not import any module of pcl. can you find a solution of your problem?

ananan commented 7 years ago

Hi, is there a way to use visualization on ubuntu now ?

Sirokujira commented 6 years ago

Path information for linking with the library of vtk can not be acquired via pkg-config (no pc file). It is necessary to obtain the path information of vtk from cmake and adopt corresponding method. Alternatively, you need to edit setup.py and use the vtk include file / library file path information to use directly.(Correspondence of Windows and pcl 1.8.1)

akahmet commented 6 years ago

After test basically you can just need to edit setup.py @ line 593

Extension("pcl.pcl_visualization", ["pcl/pcl_visualization.pyx"], language="c++",extra_compile_args=['-std=c++11'], **ext_args),

add to setup.py @ line 16

sys.path.append('./pcl') sys.path.append('/usr/local/include/vtk-9.0') sys.path.append('./tests')


after compile VTK 8.0 from source try to compile it with this option '-std=gnu++11'

aarch64-linux-gnu-gcc -std=gnu++11 -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DEIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET=1 -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/local/include/vtk-9.0 -I/usr/local/include/pcl-1.8 -I/usr/include/ni -I/usr/include/eigen3 -I/usr/include/ni -I/usr/include/python2.7 -c pcl/pcl_visualization.cpp -o build/temp.linux-aarch64-2.7/pcl/pcl_visualization.o

rybandrei2014 commented 6 years ago

Hello i have the same issue, i tried to solve it according to akahmet, i edited setup.py. But i got this problem during running setup.py script. Can you help me? It misses some point_cloud_handler.h

ros@rosthink:~/python-pcl$ sudo python2.7 setup.py install /usr/lib/python2.7/distutils/extension.py:133: UserWarning: Unknown Extension options: 'ext_args' warnings.warn(msg) running install running bdist_egg running egg_info writing requirements to python_pcl.egg-info/requires.txt writing python_pcl.egg-info/PKG-INFO writing top-level names to python_pcl.egg-info/top_level.txt writing dependency_links to python_pcl.egg-info/dependency_links.txt reading manifest file 'python_pcl.egg-info/SOURCES.txt' writing manifest file 'python_pcl.egg-info/SOURCES.txt' installing library code to build/bdist.linux-i686/egg running install_lib running build_py running build_ext skipping 'pcl/pcl_visualization.cpp' Cython extension (up-to-date) building 'pcl.pcl_visualization' extension i686-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DEIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET=1 -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/pcl-1.7 -I/usr/include/ni -I/usr/include/eigen3 -I/usr/include/ni -I/usr/include/python2.7 -c pcl/pcl_visualization.cpp -o build/temp.linux-i686-2.7/pcl/pcl_visualization.o cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ In file included from /usr/include/pcl-1.7/pcl/visualization/point_cloud_handlers.h:41:0, from pcl/pcl_visualization.cpp:469: /usr/include/pcl-1.7/pcl/visualization/point_cloud_geometry_handlers.h:48:29: fatal error: vtkSmartPointer.h: No such file or directory compilation terminated. error: command 'i686-linux-gnu-gcc' failed with exit status 1

akahmet commented 6 years ago

@dragoon000320

try to add path of VTK build to setup.py as exampl add to setup.py @ line 16

sys.path.append('./pcl') sys.path.append('/usr/local/include/vtk-9.0') sys.path.append('./tests')

PjPajkis commented 6 years ago

have the same problem on ubuntu 16.04, cannot import pcl_visualization, no solution didnt help so far, but I have vtk 7.1.

ljc19800331 commented 6 years ago

Hello, @saibash, have you solved the problem? I can import pcl but can not import other modules.

HuynhLam commented 6 years ago

Yeah, I have the same issue with Mac OS X 10.12

>>> pcl.pcl_visualization
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'pcl_visualization'
>>> import pcl.pcl_visualization
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pcl_visualization
>>> from pcl import pcl_visualization
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name pcl_visualization
>>> import pcl.pcl_registration
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pcl_registration

python pcl actually can not import any pcl module. However, pkg-config --list-all show that all the pcl module are install.

Lams-MacBook-Pro:python-pcl lhuynh$ pkg-config --list-all
cminpack                 CMINPACK - CMinPack
libecpg                  libecpg - PostgreSQL libecpg library
libpng16                 libpng - Loads and saves PNG files
fontconfig               Fontconfig - Font configuration and customization library
libpq                    libpq - PostgreSQL libpq library
pcl_apps-1.8             pcl_apps - Application examples/samples that show how PCL works
pcl_io-1.8               pcl_io - Point cloud IO library
pcl_octree-1.8           pcl_octree - Point cloud octree library
mpfr                     mpfr - C library for multiple-precision floating-point computations
pcl_keypoints-1.8        pcl_keypoints - Point cloud keypoints library
freetype2                FreeType 2 - A free, high-quality, and portable font engine.
isl                      isl - isl Library
pcl_segmentation-1.8     pcl_segmentation - Point cloud segmentation library
libtiff-4                libtiff - Tag Image File Format (TIFF) library.
libcurl                  libcurl - Library to transfer files with ftp, http, etc.
pcl_kdtree-1.8           pcl_kdtree - Point cloud kd-tree library
libpng                   libpng - Loads and saves PNG files
pcl_outofcore-1.8        pcl_outofcore - Point cloud outofcore library
pcl_search-1.8           pcl_search - Point cloud generic search library
libedit                  libedit - command line editor library provides generic line editing, history, and tokenization functions.
pcl_2d-1.8               pcl_2d - Point cloud 2d
pcl_simulation-1.8       pcl_simulation - Point Cloud Library Simulation
libpgtypes               libpgtypes - PostgreSQL libpgtypes library
pcl_ml-1.8               pcl_ml - Point cloud machine learning library
pcl_sample_consensus-1.8 pcl_sample_consensus - Point cloud sample consensus library
pcl_people-1.8           pcl_people - Point cloud people library
pcl_tracking-1.8         pcl_tracking - Point cloud tracking library
netcdf                   netCDF - NetCDF Client Library for C
flann                    flann - Fast Library for Approximate Nearest Neighbors
glew                     glew - The OpenGL Extension Wrangler library
libpcre                  libpcre - PCRE - Perl compatible regular expressions C library
pcl_filters-1.8          pcl_filters - Point cloud filters library
libcrypto                OpenSSL-libcrypto - OpenSSL cryptography library
pcl_surface-1.8          pcl_surface - Point cloud surface library
pcl_features-1.8         pcl_features - Point cloud features library
openssl                  OpenSSL - Secure Sockets Layer and cryptography libraries and tools
pcl_common-1.8           pcl_common - Point cloud common library
libpcreposix             libpcreposix - PCREPosix - Posix compatible interface to libpcre
pcl_visualization-1.8    pcl_visualization - Point cloud visualization library
libecpg_compat           libecpg_compat - PostgreSQL libecpg_compat library
libssl                   OpenSSL - Secure Sockets Layer and cryptography libraries
apr-1                    APR - The Apache Portable Runtime library
pcl_registration-1.8     pcl_registration - Point cloud registration library
libiodbc                 iODBC - iODBC Driver Manager
pcl_stereo-1.8           pcl_stereo - Point cloud stereo library
libxslt                  libxslt - XSLT library version 2.
pcl_geometry-1.8         pcl_geometry - Point cloud geometry library
pcl_recognition-1.8      pcl_recognition - Point cloud recognition library
libtls                   LibreSSL-libtls - Secure communications using the TLS socket protocol.
sqlite3                  SQLite - SQL database engine
apr-util-1               APR Utils - Companion library for APR
eigen3                   Eigen3 - A C++ template library for linear algebra: vectors, matrices, and related algorithms
libusb-1.0               libusb-1.0 - C API for USB device access from Linux, Mac OS X, Windows, OpenBSD/NetBSD and Solaris userspace
libxml-2.0               libXML - libXML library version2.
libexslt                 libexslt - EXSLT Extension library
zlib                     zlib - zlib compression library

I tried to add

sys.path.append('./pcl')
sys.path.append('/usr/local/include/vtk-8.1')
sys.path.append('./tests')

into setup.py file but it still not working. Please help !

scoswriter commented 6 years ago

This post does not directly address this issue, but several recently opened and as a forewarning more of a forum post.

When I was tinkering with the setup.py, I did not see any evidence in the build output that was impacted by adding paths, for example sys.path.append(...) at the top of the file, for which has been posted in a few issues and threads.

What did help was to add your include_dirs under the not windows build (linux) section around line 550 in setup.py. For example ext_args['include_dirs'].append('/usr/local/include/vtk-8.1')

Also if you do not remove the pcl_2d-1.8 from the installed pcl_features-1.8.pc, in a system wide install typically at /usr/lib/local/pkgconfig then the build will not properly link you will get undefined symbols when python loads the module

run ldd on the _pcl*.so target and make sure it is linked against pcl and vtk libs. Make sure you have all your lib paths defined, ext_args['library_dirs'].append('/usr/local/lib') is already there, but you may need something specific if your build are not installing system wide.

not sure if it following helps ext_args['extra_compile_args'].append("-std=c++11") ext_args['extra_compile_args'].append("-fno-strict-aliasing")

specifying the C++11 standard seemed to help others, probably to get through all the templates. lots of templates!

I did not rigorously test the above options, but it worked on my distro. (Ubuntu 16.04.1) With a system install build of VTK 1.8 and pcl 1.8.1 with cython 0.27.3 and python 3.5 only

The visualization will get built if you comment out the appropriate line at the end of the setup file. The module and the visualization loads in pycharm 2017.3 although the introspection that you'd be accustomed to is lacking since its compiled (I kinda forgot about that part and was a little disappointed by my efforts to get this to work). The expose objects and how to use them al not self explanatory and I find that I might as well use a C/C++ IDE and following the documentations for PCL directly.

There seems to be missing stuff with loaded, such as registration, but then its not a complete wrap. I have not throughly looked at the wrapping code to see what should be exposed to confirm missing objects. Many of the examples do not seem to function , but the test do seem to work and provide some guidance on how to use this wrapping.

niranjanreddy891 commented 6 years ago
    import pcl.pcl_visualization
ImportError: No module named pcl_visualization

This is the error I am facing. I can import pcl but can't import any of the pcl libraries. Can anyone help me. I am using windows7 64bit.

Braz3n commented 6 years ago

I solved this issue under Linux. Note that this is for PCL 1.8.x and VTK 7.1, but it's pretty clear how you'd modify the lines of code for other versions.

Make some modifications to the setup.py file in the python-pcl repository. Make sure you replicate the indentation of the surroundling lines of code.

  1. After line 550, add ext_args['include_dirs'].append('/usr/local/include/vtk-7.1')
  2. Near line 613, uncomment the Extension("pcl.pcl_visualization", ["pcl/pcl_visualization.pyx"], language="c++", **ext_args), line under the elif pcl_version == '-1.8': statement.
niranjanreddy891 commented 6 years ago

@HaroldMurcia, which version of pcl are you using. I had the same issue. But I solved this issue by installing pcl-1.8.1 using conda on win-7 64 bit machine. It works fine for me

anosnowhong commented 6 years ago

I got it work on ubuntu 14.04 docker, need to modify the setup.py file to get visualization module built. For PCL 1.7 and vtk-5.8, start at line 545 where the content is "pcl 1.7(Ubuntu)", Uncomment line https://github.com/strawlab/python-pcl/blob/215c89fc8fe818d44c5bd5b6f7ca9ec3dee38fa2/setup.py#L546 https://github.com/strawlab/python-pcl/blob/215c89fc8fe818d44c5bd5b6f7ca9ec3dee38fa2/setup.py#L547 Uncomment this line to build visualization https://github.com/strawlab/python-pcl/blob/215c89fc8fe818d44c5bd5b6f7ca9ec3dee38fa2/setup.py#L610

calocedrus commented 6 years ago

I've followed @anosnowhong solution and solved the pcl_visualization import error on ubuntu 16.04, pcl 1.8 and vtk 6.2.

SalahEddineGhamri commented 6 years ago

I am getting the same problem using windows 64 machine. Trying to upgrade to pcl 1.8.1 maybe this gonna solve the problem as @niranjanreddy891 mentioned.

brunohjs commented 6 years ago

I've followed @anosnowhong solution and solved the pcl_visualization import error on ubuntu 14.04 and pcl 1.7. Very thaaanks!

ShengyuH commented 6 years ago

on MacOSX 10.13, pcl 1.8.1 and vtk 8.1, I changed setup.py under line: pcl1.8.1(MacOSX), but when build it reported that "only virtual member could be marked as override", my clang version is "Apple LLVM version 9.1.0 (clang-902.0.39.1)"

saruagithub commented 6 years ago

I rerun the setup.py file. it can build 'pcl.pcl_visualization' extension @anosnowhong , however there are many errors about the virtual member in C++. /usr/local/include/vtk-8.1/vtkAOSDataArrayTemplate.h:48:3: error: only virtual member functions can be marked 'override' vtkTemplateTypeMacro(SelfType, GenericDataArrayType)

error: only virtual member functions can be marked 'override' void FillTypedComponent(int compIdx, ValueType value) override;

akjagadish commented 6 years ago

I got it to work following @Braz3n suggestion on Ubuntu

wqlu commented 5 years ago

I solved this issue under Linux. Note that this is for PCL 1.8.x and VTK 7.1, but it's pretty clear how you'd modify the lines of code for other versions.

Make some modifications to the setup.py file in the python-pcl repository. Make sure you replicate the indentation of the surroundling lines of code.

  1. After line 550, add ext_args['include_dirs'].append('/usr/local/include/vtk-7.1')
  2. Near line 613, uncomment the Extension("pcl.pcl_visualization", ["pcl/pcl_visualization.pyx"], language="c++", **ext_args), line under the elif pcl_version == '-1.8': statement.

thanks, solved this problem

ningscapr commented 5 years ago

I followed @Braz3n solution and solved the problem. Thanks!

eyildiz-ugoe commented 5 years ago

Neither of the solutions from @Braz3n nor @anosnowhong could solve the problem.

ImportError: /usr/local/lib/python2.7/dist-packages/python_pcl-0.3-py2.7-linux-x86_64.egg/pcl/pcl_visualization.so: undefined symbol: _ZN31vtkObjectFactoryRegistryCleanupD1Ev

improve100 commented 5 years ago
  1. ext_args['include_dirs'].append('/usr/local/include/vtk-7.1')

ImportError: /home/xxx/.pyenv/versions/env3.6.0/lib/python3.6/site-packages/python_pcl-0.3-py3.6-linux-x86_64.egg/pcl/pcl_visualization.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZN31vtkObjectFactoryRegistryCleanupD1Ev

RyanHangZhou commented 5 years ago

I solved this issue under Linux. Note that this is for PCL 1.8.x and VTK 7.1, but it's pretty clear how you'd modify the lines of code for other versions.

Make some modifications to the setup.py file in the python-pcl repository. Make sure you replicate the indentation of the surroundling lines of code.

1. After line 550, add `ext_args['include_dirs'].append('/usr/local/include/vtk-7.1')`

2. Near line 613, uncomment the `Extension("pcl.pcl_visualization", ["pcl/pcl_visualization.pyx"], language="c++", **ext_args),` line under the `elif pcl_version == '-1.8':` statement.

so thankful!

zorosmith commented 5 years ago

Make sure you replicate the indentation of the surroundling lines of code!!!!

chris-aeviator commented 3 years ago

could someone re-publish a pip for the linux & visualization enabled python-pcl?