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

Error occurs when I install pygicp using Python3... (ImportError) #66

Open
hyxhope opened this issue Jul 29, 2021 · 5 comments
Open

Error occurs when I install pygicp using Python3... (ImportError) #66

hyxhope opened this issue Jul 29, 2021 · 5 comments

Comments

@hyxhope
Copy link

hyxhope commented Jul 29, 2021

Your C++ code compiles without any error! All ok!
Then when i install pygicp, no error again.

creating build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-3.8/libfast_gicp.so -> build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-3.8/pygicp.cpython-38-x86_64-linux-gnu.so -> build/bdist.linux-x86_64/egg
creating stub loader for pygicp.cpython-38-x86_64-linux-gnu.so
byte-compiling build/bdist.linux-x86_64/egg/pygicp.py to pygicp.cpython-38.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying pygicp.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pygicp.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pygicp.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pygicp.egg-info/not-zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pygicp.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
creating 'dist/pygicp-0.0.1-py3.8-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing pygicp-0.0.1-py3.8-linux-x86_64.egg
creating /home/hyx/miniconda3/envs/slam/lib/python3.8/site-packages/pygicp-0.0.1-py3.8-linux-x86_64.egg
Extracting pygicp-0.0.1-py3.8-linux-x86_64.egg to /home/hyx/miniconda3/envs/slam/lib/python3.8/site-packages
Adding pygicp 0.0.1 to easy-install.pth file

Installed /home/hyx/miniconda3/envs/slam/lib/python3.8/site-packages/pygicp-0.0.1-py3.8-linux-x86_64.egg
Processing dependencies for pygicp==0.0.1
Finished processing dependencies for pygicp==0.0.1

But when i import pygicp in Python3, error occurs.

import pygicp
Traceback (most recent call last):
File "", line 1, in
ImportError: dynamic module does not define module export function (PyInit_pygicp)

But when i install it using Py2, everything is ok.
So,
How can I fix this Python3 import error?
Thanks a lot!

@koide3
Copy link
Member

koide3 commented Jul 29, 2021

It seems the package was installed to your python2 environment. Try the following installation command (don't forget "3" after python)

python3 setup.py install --user

@nightfox0909
Copy link

I had this issue too, seems like pcl introduces a dependency on /usr/bin/python2.7 as mentioned here and here. To check if this is what is causing your issues, take a look at the build/temp./Cmakefiles/pygicp.dir/flags.make, you should find -I /usr/bin/python2.7 . As a temporary workaround, two approaches worked for me

  1. renaming /usr/bin/python2.7 to something else, installing the package with setup.py as mentioned above and then renaming the folder back to python2.7. This is hacky, but the easiest workaround for the issue.
  2. A slightly better but still hacky way is to use regexes to filter out python2.7 in the cmakelists file from PCL_INCLUDE_DIRS and the INCLUDE_DIRS for pygicp and fast_gicp.

@HViktorTsoi
Copy link
Contributor

HViktorTsoi commented Mar 25, 2022

I had this issue too, seems like pcl introduces a dependency on /usr/bin/python2.7 as mentioned here and here. To check if this is what is causing your issues, take a look at the build/temp./Cmakefiles/pygicp.dir/flags.make, you should find -I /usr/bin/python2.7 . As a temporary workaround, two approaches worked for me

  1. renaming /usr/bin/python2.7 to something else, installing the package with setup.py as mentioned above and then renaming the folder back to python2.7. This is hacky, but the easiest workaround for the issue.
  2. A slightly better but still hacky way is to use regexes to filter out python2.7 in the cmakelists file from PCL_INCLUDE_DIRS and the INCLUDE_DIRS for pygicp and fast_gicp.

Approache 1 worked, but it should be renaming /usr/include/python2.7 to somewhere else, rahter than /usr/bin/python2.7

@iamwilliamli
Copy link

I had this issue too, seems like pcl introduces a dependency on /usr/bin/python2.7 as mentioned here and here. To check if this is what is causing your issues, take a look at the build/temp./Cmakefiles/pygicp.dir/flags.make, you should find -I /usr/bin/python2.7 . As a temporary workaround, two approaches worked for me

  1. renaming /usr/bin/python2.7 to something else, installing the package with setup.py as mentioned above and then renaming the folder back to python2.7. This is hacky, but the easiest workaround for the issue.
  2. A slightly better but still hacky way is to use regexes to filter out python2.7 in the cmakelists file from PCL_INCLUDE_DIRS and the INCLUDE_DIRS for pygicp and fast_gicp.

This is not working for me.

import pygicp
Traceback (most recent call last):
File "", line 1, in
ImportError: dynamic module does not define module export function (PyInit_pygicp)

@AndreejS
Copy link

Approache 1 worked, but it should be renaming /usr/include/python2.7 to somewhere else, rahter than /usr/bin/python2.7

I can confirm this was also the case for me.
However, it seems to depend only on what is used in build/temp./Cmakefiles/pygicp.dir/flags.make, so i'd suggest to verify which path is used there and rename that one.

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

6 participants