hfutcgncas / normalSpeed

A fast algorithm for comupting the normal of the depth img. And warp it by pybind11 as python3 interface.
26 stars 10 forks source link

module 'normalSpeed' has no attribute 'depth_normal' #7

Closed an99990 closed 3 years ago

an99990 commented 3 years ago

After installing all dependencies, I wanted to test and run the example.py Installation seems to be successful.

running install
Checking .pth file support in /home/halodi/.local/lib/python3.6/site-packages/
/home/halodi/.local/share/virtualenvs/test_2_venv-IQxQe5Zj/bin/python3 -E -c pass
TEST FAILED: /home/halodi/.local/lib/python3.6/site-packages/ does NOT support .pth files
bad install directory or PYTHONPATH

You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from.  The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /home/halodi/.local/lib/python3.6/site-packages/

and your PYTHONPATH environment variable currently contains:

    '/opt/ros/foxy/lib/python3.8/site-packages'

Here are some of your options for correcting the problem:

* You can choose a different installation directory, i.e., one that is
  on PYTHONPATH or supports .pth files

* You can add the installation directory to the PYTHONPATH environment
  variable.  (It must then also be on PYTHONPATH whenever you run
  Python and want to use the package(s) you are installing.)

* You can set up the installation directory to support ".pth" files by
  using one of the approaches described here:

  https://setuptools.readthedocs.io/en/latest/easy_install.html#custom-installation-locations

Please make the appropriate changes for your system and try again.
running bdist_egg
running egg_info
writing normalSpeed.egg-info/PKG-INFO
writing dependency_links to normalSpeed.egg-info/dependency_links.txt
writing top-level names to normalSpeed.egg-info/top_level.txt
reading manifest file 'normalSpeed.egg-info/SOURCES.txt'
writing manifest file 'normalSpeed.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_ext
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- Found pybind11: /home/halodi/.local/share/virtualenvs/test_2_venv-IQxQe5Zj/include (found version "2.7.1" )
CMake Deprecation Warning at Cmake/FindNumPy.cmake:6 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.
Call Stack (most recent call first):
  CMakeLists.txt:14 (include)

-- Configuring done
-- Generating done
-- Build files have been written to: /home/halodi/test_2_venv/normalSpeed/normalSpeed/build/temp.linux-x86_64-3.6
Consolidate compiler generated dependencies of target normalSpeed
[ 25%] Building CXX object CMakeFiles/normalSpeed.dir/pybind11.cpp.o
[ 50%] Building CXX object CMakeFiles/normalSpeed.dir/np2mat/ndarray_converter.cpp.o
[ 75%] Linking CXX shared module ../lib.linux-x86_64-3.6/normalSpeed.cpython-36m-x86_64-linux-gnu.so
[100%] Built target normalSpeed
creating build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-3.6/normalSpeed.cpython-36m-x86_64-linux-gnu.so -> build/bdist.linux-x86_64/egg
warning: install_lib: byte-compiling is disabled, skipping.

creating stub loader for normalSpeed.cpython-36m-x86_64-linux-gnu.so
warning: install_lib: byte-compiling is disabled, skipping.

creating build/bdist.linux-x86_64/egg/EGG-INFO
copying normalSpeed.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying normalSpeed.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying normalSpeed.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying normalSpeed.egg-info/not-zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO
copying normalSpeed.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/normalSpeed-0.0.1-py3.6-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 normalSpeed-0.0.1-py3.6-linux-x86_64.egg
removing '/home/halodi/.local/lib/python3.6/site-packages/normalSpeed-0.0.1-py3.6-linux-x86_64.egg' (and everything under it)
creating /home/halodi/.local/lib/python3.6/site-packages/normalSpeed-0.0.1-py3.6-linux-x86_64.egg
Extracting normalSpeed-0.0.1-py3.6-linux-x86_64.egg to /home/halodi/.local/lib/python3.6/site-packages

Installed /home/halodi/.local/lib/python3.6/site-packages/normalSpeed-0.0.1-py3.6-linux-x86_64.egg
Processing dependencies for normalSpeed==0.0.1
Finished processing dependencies for normalSpeed==0.0.1

the error message is

Traceback (most recent call last):
  File "example.py", line 39, in <module>
    normals_map_out = normalSpeed.depth_normal(depth, fx, fy, k_size, distance_threshold, difference_threshold, point_into_surface)
AttributeError: module 'normalSpeed' has no attribute 'depth_normal'

Please advise @ethnhe

ethnhe commented 3 years ago

It seems you have various versions of python. Did you use python3.6 to run the example.py? There is a warning in your installation

You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from.  The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /home/halodi/.local/lib/python3.6/site-packages/

and your PYTHONPATH environment variable currently contains:

    '/opt/ros/foxy/lib/python3.8/site-packages'

Here are some of your options for correcting the problem:

* You can choose a different installation directory, i.e., one that is
  on PYTHONPATH or supports .pth files

* You can add the installation directory to the PYTHONPATH environment
  variable.  (It must then also be on PYTHONPATH whenever you run
  Python and want to use the package(s) you are installing.)

* You can set up the installation directory to support ".pth" files by
  using one of the approaches described here:

  https://setuptools.readthedocs.io/en/latest/easy_install.html#custom-installation-locations

You can first try to compile the normal speed in the folder following:

cd normalSpeed
python3 setup.py build_ext --inplace
cd .. && cp normalSpeed/normalSpeed.* ./

You will get a compiled .so file. For example, normalSpeed.cpython-36m-x86_64-linux-gnu.so, here *36m* means python3.6, if you use python3.8 to import such .so, there will be some error.

an99990 commented 3 years ago

thank you for your answer. These are the results python3 setup.py build_ext --inplace

running build_ext
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- Found pybind11: /home/halodi/.local/share/virtualenvs/test_2_venv-IQxQe5Zj/include (found version "2.7.1" )
CMake Deprecation Warning at Cmake/FindNumPy.cmake:6 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.
Call Stack (most recent call first):
  CMakeLists.txt:14 (include)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/halodi/test_2_venv/normalSpeed/normalSpeed/build/temp.linux-x86_64-3.6

then cd .. && cp normalSpeed/normalSpeed.* ./ cp: -r not specified; omitting directory 'normalSpeed/normalSpeed.egg-info' then if i run example.py

Traceback (most recent call last):
  File "example.py", line 6, in <module>
    import normalSpeed
ImportError: /home/halodi/test_2_venv/normalSpeed/normalSpeed.cpython-36m-x86_64-linux-gnu.so: undefined symbol: PyThread_tss_get

please help @ethnhe

ethnhe commented 3 years ago

Strange then, did you use python3.6 to run the example.py? Try to specify the python version, maybe by:

/usr/bin/python3.6 example.py
an99990 commented 3 years ago

so i dont get the previous error but now it doesnt see my packages. The thing is that im working in a venv pipenv. so i tried /usr/bin/python3.6 example.py : gives no module name cv2 pipenv run python3 example.py : gives the PyThread_tss_get error pipenv run /usr/bin/python3.6 example.py : gives no module name cv2

Traceback (most recent call last):
  File "example.py", line 4, in <module>
    from cv2 import imshow, waitKey, imwrite
ModuleNotFoundError: No module named 'cv2'

pipenv graph gives me :

apex==0.1
cffi==1.11.5
  - pycparser [required: Any, installed: 2.20]
easydict==1.7
enum34==1.1.10
future==0.18.2
glumpy==1.0.6
  - cython [required: Any, installed: 0.29.24]
  - numpy [required: Any, installed: 1.19.5]
  - triangle [required: Any, installed: 20200424]
    - numpy [required: Any, installed: 1.19.5]
h5py==3.1.0
  - cached-property [required: Any, installed: 1.5.2]
  - numpy [required: >=1.12, installed: 1.19.5]
lmdb==0.94
opencv-contrib-python==3.4.2.16
  - numpy [required: >=1.11.3, installed: 1.19.5]
opencv-python==4.5.3.56
  - numpy [required: >=1.13.3, installed: 1.19.5]
pandas==1.1.5
  - numpy [required: >=1.15.4, installed: 1.19.5]
  - python-dateutil [required: >=2.7.3, installed: 2.8.2]
    - six [required: >=1.5, installed: 1.16.0]
  - pytz [required: >=2017.2, installed: 2021.1]
plyfile==0.6
  - numpy [required: >=1.8, installed: 1.19.5]
pprintpp==0.4.0
pybind11==2.7.1
pybind11-global==2.7.1
PyYAML==5.4.1
scikit-image==0.13.1
  - matplotlib [required: >=1.3.1, installed: 3.0.2]
    - cycler [required: >=0.10, installed: 0.10.0]
      - six [required: Any, installed: 1.16.0]
    - kiwisolver [required: >=1.0.1, installed: 1.3.1]
    - numpy [required: >=1.10.0, installed: 1.19.5]
    - pyparsing [required: >=2.0.1,!=2.1.6,!=2.1.2,!=2.0.4, installed: 2.4.7]
    - python-dateutil [required: >=2.1, installed: 2.8.2]
      - six [required: >=1.5, installed: 1.16.0]
  - networkx [required: >=1.8, installed: 2.5.1]
    - decorator [required: >=4.3,<5, installed: 4.4.2]
  - pillow [required: >=2.1.0, installed: 8.2.0]
  - PyWavelets [required: >=0.4.0, installed: 1.1.1]
    - numpy [required: >=1.13.3, installed: 1.19.5]
  - scipy [required: >=0.17.0, installed: 1.4.1]
    - numpy [required: >=1.13.3, installed: 1.19.5]
  - six [required: >=1.7.3, installed: 1.16.0]
sklearn==0.0
  - scikit-learn [required: Any, installed: 0.24.2]
    - joblib [required: >=0.11, installed: 1.0.1]
    - numpy [required: >=1.13.3, installed: 1.19.5]
    - scipy [required: >=0.19.1, installed: 1.4.1]
      - numpy [required: >=1.13.3, installed: 1.19.5]
    - threadpoolctl [required: >=2.0.0, installed: 2.2.0]
torchvision==0.2.0
  - numpy [required: Any, installed: 1.19.5]
  - pillow [required: >=4.1.1, installed: 8.2.0]
  - six [required: Any, installed: 1.16.0]
  - torch [required: Any, installed: 1.4.0]
transforms3d==0.3.1

thank you please help @ethnhe

ethnhe commented 3 years ago

Sorry that I'm not familiar with pipenv. Maybe you need to search for the solution on the internet.

an99990 commented 3 years ago

ok so I was able to install it with /usr/bin/python3.6 -m pip install opencv-python but now i have the same issue of earlier.

Traceback (most recent call last):
  File "example.py", line 6, in <module>
    import normalSpeed
ImportError: /home/halodi/test_2_venv/normalSpeed/normalSpeed.cpython-36m-x86_64-linux-gnu.so: undefined symbol: PyThread_tss_get

so i think the issue is opencv python version

an99990 commented 3 years ago

Update I was able to run the xample with python 3.8 and opencv4. Thanks for all the support