Closed moon05 closed 6 years ago
I think you may have misread our instructions. If you simply wish to test OpenPose Python, you must navigate to the python directory in the Python Build Folder as seen in the instructions (https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/doc/modules/python_module.md)
# From command line
cd build/examples/tutorial_python
python 1_extract_pose.py
If you wish to access the library from another location, you need to add the python folder to your PYTHONPATH. This can be done with adding it to your system path or appending the environmental variable directly. This can be seen in the example code as well
else: sys.path.append('../../python');
# Option b
# If you run `make install` (default path is `/usr/local/python` for Ubuntu), you can also access the OpenPose/python module from there. This will install OpenPose and the python library at your desired installation path. Ensure that this is in your python path in order to use it.
# sys.path.append('/usr/local/python')
In your case, you have installed openpose already to /usr/local/ so you need to add sys.path.append('/usr/local/python') instead of hacking the path of openpose.so directly into the python library. You have linked to the wrong .so library anyway so it can't find the symbol. Your python path is also pointing to the source directory openpose/python instead of openpose/build/python. If this folder is missing, it means you did not enabled BUILD_PYTHON. Please try to take a look at the examples and read the instructions to see how its done.
Lastly, the Python example currently does not allow command line inputs. It was more to serve as an example of what variables can be changed. But we can see how this can be confusing as the C++ code can do this, so we could add this in the future
Well regardless of the path problem, which probably is my misunderstanding the "undefined symbol" error remains. I simply added the command line inputs just because that was the format to post an issue. Without the command line args I still get the same error. Any solution?
Can you navigate to the example python code and run it does it work? We don't officially test it on 18.04 so there may be some unknown errors.
It doesn't. I was going to start another issue for the Jetson TX2 I am using to do the same, with Tegra-Ubuntu version 16.04.4. But in that installation even after building everything properly and adding the PATH properly, I can't even find the openpose lib (openpose.so) anywhere. In the Jetson installation I am still stuck at the following error:
Traceback (most recent call last):
File "test.py", line 18, in
It looks like youre navigating to the wrong path. Youre suppose to navigate to the build directory.
Generally alot of libraries do copy the .so file back to the source directory, but we did not want to do this as it would mean making it confusing if you have multiple builds for different versions of compiled openpose.
Did you mean I would have to go the build directory and execute the example from there? Because I just tried that and I still got the same error. Just to make sure I am following what you are saying here's the error, and see the location I am at:
abdullah@abdullah-MacBookPro:~/Desktop/openpose/build/examples/tutorial_python$ python 1_extract_pose.py
Traceback (most recent call last):
File "1_extract_pose.py", line 6, in
Can you navigate to build/python/openpose and tell me if you see a file called _openpose.so
This is where I can see python dir which is in the src dir inside build. Like the following
~/Desktop/openpose/build/src/openpose$ ls
3d cmake_install.cmake filestream hand Makefile producer utilities
calibration core gpu libopenpose.so net thread wrapper
CMakeFiles face gui libopenpose.so.1.3.0 pose tracking
abdullah@abdullah-MacBookPro:~/Desktop/openpose/build/src/openpose$ pwd
/home/abdullah/Desktop/openpose/build/src/openpose
abdullah@abdullah-MacBookPro:~/Desktop/openpose/build/src/openpose$
Believe it or not there is no python directory inside build.
abdullah@abdullah-MacBookPro:~/Desktop/openpose/build$ ls
caffe CMakeCache.txt cmake_install.cmake examples Makefile
cmake CMakeFiles cmake_uninstall.cmake install_manifest.txt src
abdullah@abdullah-MacBookPro:~/Desktop/openpose/build$
That is because you have not enabled BUILD_PYTHON perhaps. Have you tried that
I will do another fresh build right now, to see if that works and if I forgot to enable it! I will update you as soon as I am done! Thanks for such quick replies!
No problem. Do consider reading through the build instructions more thoroughly next time, and also let us know if anything is confusing.
Okay I did a new build with BUILD_PYTHON. _openpose.so exists:
abdullah@abdullah-MacBookPro:~/Desktop/openpose/build/python/openpose$ ls
CMakeFiles __init__.py openpose.py
cmake_install.cmake Makefile _openpose.so
abdullah@abdullah-MacBookPro:~/Desktop/openpose/build/python/openpose$
I am still getting the error:
abdullah@abdullah-MacBookPro:~/Desktop/openpose/build/examples/tutorial_python$ python 1_extract_pose.py
Traceback (most recent call last):
File "1_extract_pose.py", line 6, in <module>
from openpose import *
File "/home/abdullah/Desktop/openpose/python/openpose/__init__.py", line 1, in <module>
from openpose import *
File "/home/abdullah/Desktop/openpose/python/openpose/openpose.py", line 12, in <module>
class OpenPose(object):
File "/home/abdullah/Desktop/openpose/python/openpose/openpose.py", line 20, in OpenPose
ct.c_int, ct.c_char_p, ct.c_char_p, ct.c_char_p, ct.c_float, ct.c_float, ct.c_int, ct.c_float, ct.c_int, ct.c_bool, ct.c_char_p]
File "/usr/lib/python2.7/ctypes/__init__.py", line 379, in __getattr__
func = self.__getitem__(name)
File "/usr/lib/python2.7/ctypes/__init__.py", line 384, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /usr/local/lib/libopenpose.so: undefined symbol: newOP
Am I missing something here? Or just clearly not understanding some plain instruction?
I am not sure why your code is linking to the src directory again. "python/openpose/init.py"
The Python API must link to the build directory and it does. I think you may have made some modifications to either the code or your environment variables. I would suggest a clean install with wiping of your environmental variables etc.
Finally got it to work. @soulslicer you were probably saying this the whole time but I didn't quite get it. Anyhow this is the path I included in my $PYTHONPATH and it worked :
/home/nvidia/caffe/python:/home/nvidia/openpose/build/python/:
Also, if anyone else faces this just a summary:
sudo make install
after the building is done, that does the linkingFinally run it from here: ~/Desktop/openpose/build/example/tutorial_python
It is not required to do sudo make install. You simply need to set your PYTHONPATH accordingly as per the instruction and the examples provided.
Oh alright! Nonetheless, hopefully I didn't create unnecessary chain of comments!
I followed the instructions. But I got the same error like this:
Traceback (most recent call last):
File "test.py", line 8, in
Issue Summary
Either "_openpose.so" not found or if that is fixed then there's an undefined symbol error. As a result can't even run the example python script.
In openpose.py (location: openpose/python/openpose/openpose.py) I had to change line 16 to the following for it to work:
_libop= np.ctypeslib.load_library('libopenpose','/usr/local/lib/libopenpose.so')
Also I just wanted to include what my PYTHONPATH looks like:
echo $PYTHONPATH
/home/abdullah/caffe/python/:/home/abdullah/Desktop/openpose/python/
Executed Command (if any)
python 1_extract_pose.py --logging_level 0 --disable_multi_thread
OpenPose Output (if any)
Traceback (most recent call last): File "1_extract_pose.py", line 6, in
from openpose import
File "/home/abdullah/Desktop/openpose/python/openpose/init.py", line 1, in
from openpose import
File "/home/abdullah/Desktop/openpose/python/openpose/openpose.py", line 12, in
class OpenPose(object):
File "/home/abdullah/Desktop/openpose/python/openpose/openpose.py", line 20, in OpenPose
ct.c_int, ct.c_char_p, ct.c_char_p, ct.c_char_p, ct.c_float, ct.c_float, ct.c_int, ct.c_float, ct.c_int, ct.c_bool, ct.c_char_p]
File "/usr/lib/python2.7/ctypes/init.py", line 379, in getattr
func = self.getitem(name)
File "/usr/lib/python2.7/ctypes/init.py", line 384, in getitem
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /usr/local/lib/libopenpose.so: undefined symbol: newOP
Type of Issue
You might select multiple topics, delete the rest:
Your System Configuration
OpenPose version: Latest Github Code
General configuration:
lsb_release -a
in Ubuntu): Ubuntu 18.04 LTSgcc --version
in Ubuntu or VS version in Windows): 7.3.0 (Ubuntu)Non-default settings:
3rd-party software:
cmake --version
in Ubuntu): 3.10.2If CPU-only mode issue: