Openpose: Unable to run Python API on windows using default configuration and installation

Created on 2 Aug 2018  Â·  9Comments  Â·  Source: CMU-Perceptual-Computing-Lab/openpose

Issue Summary

I have also been having trouble running the python API for windows.

After verifying that the source code compiled and the demo worked, I am now trying to use the Python API. However, by following the instructions (found here) and trying to run 1_extract_pose.py, I receive the following error:

Error: OpenPose library could not be found. Did you enableBUILD_PYTHONin CMake and have this Python script in the right folder?
This error is thrown as a result of a failed import (lines 18-21 in 1_extract_pose.py). I already have BUILD_PYTHON set to ON and have re built the project using Cmake and VS2015.

I thought that this resulted from something wrong with the path, so I hardcoded the path to the build/python/openpose/ directory and then got a different error on line 37 when it says it can't find the OpenPose class (despite the import appearing to work).
However, when printing dir(openpose) after the import to the absolute system path, OpenPose does not appear in the list.

Additionally, I tried adding the absolute path to my environment variables, and then using import openpose in python3.6 IDLE and received the following error:

Traceback (most recent call last):
  File "C:\Users\bencj\Documents\Development\openpose\build\python\openpose\openpose.py", line 27, in OpenPose
    _libop= np.ctypeslib.load_library('_openpose', dir_path+'/Release/_openpose.dll')
  File "C:\Users\bencj\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\ctypeslib.py", line 155, in load_library
    raise OSError("no file with expected extension")
OSError: no file with expected extension

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import openpose
  File "C:\Users\bencj\Documents\Development\openpose\build\python\openpose\openpose.py", line 17, in <module>
    class OpenPose(object):
  File "C:\Users\bencj\Documents\Development\openpose\build\python\openpose\openpose.py", line 29, in OpenPose
    _libop= np.ctypeslib.load_library('_openpose', dir_path+'/Debug/_openpose.dll')
  File "C:\Users\bencj\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\ctypeslib.py", line 155, in load_library
    raise OSError("no file with expected extension")
OSError: no file with expected extension

Which once again appears to be an issue with the paths used for load_libraries. Has anyone else had similar issues? Am I potentially doing something wrong when running cmake and compiling through VS2015? I followed the setup instructions exactly and have confirmed that the demo works.

Type of Issue

  • Compilation/installation error
  • Execution error

Your System Configuration

  1. Latest GitHub code

  2. General configuration:

    • Installation mode: CMake Windows, VSCode2015 for build compilation
    • Operating system: Windows
    • Release or Debug mode: Release
    • Compiler: VS2015 community
  3. Non-default settings:
    None

  4. 3rd-party software:

    • Caffe version: Default from OpenPose
    • CMake version: 3.12.0
    • OpenCV version: OpenPose default (only Windows)
  5. If GPU mode issue:

    • CUDA version: 8
    • cuDNN version: Unsure?
    • GPU model: Nvidia 960m
  6. If Python API:

    • Python version: 3.6
    • Numpy version: 1.15.0
  7. If Windows system:
    compiled library

help wantequestion

All 9 comments

I use win10 and had the same question. I also tried to hardcode the path of openpose lib but still it still can't work.

Could you tell me all the files located in your windows build directory?

I have same problem, and I didn't find _openpose.dll under Release. It only has openpose.dll. btw, build Install doesn't copy binary to program files folder

This is everything in the build/release directory:

└───Release
        boost_chrono-vc140-mt-1_61.dll
        boost_filesystem-vc140-mt-1_61.dll
        boost_python-vc140-mt-1_61.dll
        boost_system-vc140-mt-1_61.dll
        boost_system-vc140-mt-gd-1_61.dll
        boost_thread-vc140-mt-1_61.dll
        caffe.dll
        caffehdf5.dll
        caffehdf5_hl.dll
        caffezlib1.dll
        cublas64_80.dll
        cudart64_80.dll
        cudnn64_5.dll
        curand64_80.dll
        gflags.dll
        gflagsd.dll
        glog.dll
        glogd.dll
        libgcc_s_seh-1.dll
        libgfortran-3.dll
        libopenblas.dll
        libquadmath-0.dll
        opencv_core310.dll
        opencv_ffmpeg310_64.dll
        opencv_imgcodecs310.dll
        opencv_imgproc310.dll
        opencv_world310.dll
        opencv_world310d.dll
        openpose.dll
        OpenPoseDemo.exe
        python27.dll
        VCRUNTIME140.dll

My build/python contains the following:

│   cmake_install.cmake
│   INSTALL.vcxproj
│   INSTALL.vcxproj.filters
│
├───CMakeFiles
│       generate.stamp
│       generate.stamp.depend
│
└───openpose
    │   cmake_install.cmake
    │   INSTALL.vcxproj
    │   INSTALL.vcxproj.filters
    │   openpose.py
    │   _openpose.vcxproj
    │   _openpose.vcxproj.filters
    │   __init__.py
    │
    └───CMakeFiles
            generate.stamp
            generate.stamp.depend

My problem is resolved. The key is adding "buildpythonopenpose" into PYTHONPATH.

@garyli03

Openpose does this automatically by adding it to your PYTHONPATH. This can be seen from the following code in openpose.py:

if platform == "win32":
    os.environ['PATH'] = dir_path + "/../../lib;" + os.environ['PATH']
    os.environ['PATH'] = dir_path + "/../../x64/Release;" + os.environ['PATH']

You need to make sure you run Openpose directly from the tutorial_python folder

@flpymonkey

It looks like you may have built it incorrectly, or it may have failed to build. openpose\build\python\openpose is suppose to contain a Debug/Release folder which should contain _openpose.dll

It should be as simple as compiling in Release ideally, everything by default, and navigating to build/examples/tutorial/python and then running python 1_extract_pose.py

@flpymonkey, you are right. I found these dlls in that folder, and all my build succeeded. I am using PYTHONPATH because it allows me to run my codes at anywhere.

Ok please close this issue if you have no further problems

Was this page helpful?
0 / 5 - 0 ratings

Related issues

archenroot picture archenroot  Â·  4Comments

iremozkal picture iremozkal  Â·  3Comments

ieyer picture ieyer  Â·  5Comments

vasavig picture vasavig  Â·  3Comments

ran2207 picture ran2207  Â·  3Comments