Openpose: _openpose.dll is not generated on Windows

Created on 28 Nov 2018  路  15Comments  路  Source: CMU-Perceptual-Computing-Lab/openpose

Issue Summary

I've been trying to run the python API, but I get the following error when I try to run the example.
Exception: Error: OpenPose library could not be found. Did you enableBUILD_PYTHONin CMake and have this Python script in the right folder?

The normal demo is working, it is just the python part that has a problem as far as I can tell. Reading through issue #768 it looks like the problem is that _openpose.dll is not generated, but I can not seem to find any solution to the problem. I tried rebuilding and reinstalling OpenPose a few times on different computers both running windows but the issue remains the same. In CMake BUILD_PYTHON is ON.

Executed Command (if any)

openpose-master\build\examples\tutorial_api_python> python 1_extract_pose.py

OpenPose Output (if any)

Errors (if any)

`Traceback (most recent call last):
File "C:\Users\falle\Desktop\openpose-masterbuild\examples\tutorial_api_python/../../python/openpose\openpose.py", line 27, in OpenPose
_libop= np.ctypeslib.load_library('_openpose', dir_path+'/Release/_openpose.dll')
File "D:\Anaconda3\lib\site-packages\numpyctypeslib.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 "1_extract_pose.py", line 19, in
from openpose import *
File "C:\Users\falle\Desktop\openpose-masterbuild\examples\tutorial_api_python/../../python/openpose\openpose.py", line 17, in
class OpenPose(object):
File "C:\Users\falle\Desktop\openpose-masterbuild\examples\tutorial_api_python/../../python/openpose\openpose.py", line 29, in OpenPose
_libop= np.ctypeslib.load_library('_openpose', dir_path+'/Debug/_openpose.dll')
File "D:\Anaconda3\lib\site-packages\numpyctypeslib.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 "1_extract_pose.py", line 21, in
raise Exception('Error: OpenPose library could not be found. Did you enable BUILD_PYTHON in CMake and have this Python script in the right folder?')
Exception: Error: OpenPose library could not be found. Did you enable BUILD_PYTHON in CMake and have this Python script in the right folder?`

Type of Issue

  • Compilation/installation error
  • Execution error

Your System Configuration

  1. Whole console output (if errors appeared), paste the error to PasteBin and then paste the link here: LINK

  2. OpenPose version:
    Latest GitHub code

  3. General configuration:

    • Installation mode: CMake Windows, VSCode2015 for build compilation
    • Operating system (lsb_release -a in Ubuntu): Windows 10
    • Release or Debug mode? (by default: release):Release
    • Compiler (gcc --version in Ubuntu or VS version in Windows): VS2015 Comunity
  4. Non-default settings:
    None

  5. 3rd-party software:

    • Caffe version: Default from OpenPose
    • CMake version : 3.12.3
    • OpenCV version: OpenPose default (only Windows)
  6. If Python API:

    • Python version: 3.7
    • Numpy version : 1.15.1
  7. If Windows system:
    compiled library

Most helpful comment

I had a similar issue with similar configuration but with visual studio 15.0. I am pretty sure that the issue is that while you are compiling in visual studio, it tries to import cv2 (python-opencv) and it fails. So make sure that if you open cmd.exe and run python, you can actually import cv2 without errors. I couldn't, but I had cv2 installed in a python environment (using anaconda), so I activated that environment, and then ran:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild.exe C:\path\to\OpenPose.sln

(change this to adapt it to your visual studio version and location of OpenPose.sln)

And it worked! After 6 hours of painful trial and error!

All 15 comments

I had a similar issue with similar configuration but with visual studio 15.0. I am pretty sure that the issue is that while you are compiling in visual studio, it tries to import cv2 (python-opencv) and it fails. So make sure that if you open cmd.exe and run python, you can actually import cv2 without errors. I couldn't, but I had cv2 installed in a python environment (using anaconda), so I activated that environment, and then ran:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild.exe C:\path\to\OpenPose.sln

(change this to adapt it to your visual studio version and location of OpenPose.sln)

And it worked! After 6 hours of painful trial and error!

@martinarielhartmann Thanks for your sharing!

I have verified my "import cv2" works.
img

But when I use your command to build
img

I still cannot get _openpose.dll in build\python\openposeRelease
img

The build succeeded with no errors. (I already ran the demo successfully with VS 2015 once, but I tried your command to make sure I didn't miss anything) I have my build log here, could you tell me what's wrong?

I have tried many things but can't get it work. Thanks in advance!

Please, try the latest version. It should have been fixed in there. Thanks!

Thanks for replying!

I clone openpose 3 hours ago, and it contains the latest commit f3ab8de.
img

I am not sure what kind of information should I provide, so I listed my files under build directory here.
(Sorry it's in Chinese, I want to show that the modified date is 2019/01/13 7:54 PM)

Can you kindly tell me what's the problem I need to solve and how? (In my understanding, I should generate _openpose.dll in build\python\openposeRelease) I really appreciate your help!

What I mean is that _openpose was renamed as openpose_python for higher clarity (and we are debating whether to renamed it as pyopenpose in the next commit). So you should not look for _openpose but rather for openpose_python

We are using a completely new API now for Python. Please take a look at the updated instructions.

You need to enable BUILD_PYTHON in the Cmake GUI.

Then run one of the examples directly.

Eg:

cd build/examples/tutorial_api_python; python 1_body_from_image.py

Depending on your compile mode, you may have to change these parts of the file:

        # Change these variables to point to the correct folder (Release/x64 etc.) 
        sys.path.append(dir_path + '/../../python/openpose/Release');
        os.environ['PATH']  = os.environ['PATH'] + ';' + dir_path + '/../../x64/Release;' +  dir_path + '/../../bin;'

For example, if you are in Debug mode, change the paths from Release to Debug. If you are using a non 64 bit machine, change x64 to x86 etc.

Thanks for both your comment! I really appreciated your help.

I did enabled BUILD_PYTHON in the Cmake GUI. Good thing is, after rebuild in VS2015 Enterprise, I can now see the pyd file. (I am not sure why there's nothing when I successfully ran the demo, only after rebuild, I got a pyd file in build\python\openposeRelease)
img

After modifying the file path in build/examples/tutorial_api_python/1_body_from_image.py, I got AttributeError: module 'openpose_python' has no attribute 'WrapperPython':

C:\Users\rosindigo\Documents\GitHub\openpose\build\examples\tutorial_api_python>python 1_body_from_image.py
Traceback (most recent call last):
  File "1_body_from_image.py", line 19, in <module>
    import openpose_python as op
  File "C:\Users\rosindigo\Documents\GitHub\openpose\build\examples\tutorial_api_python\openpose_python.py", line 53, in <module>
    opWrapper = op.WrapperPython(3)
AttributeError: module 'openpose_python' has no attribute 'WrapperPython'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "1_body_from_image.py", line 27, in <module>
    raise Exception('Error: OpenPose library could not be found. Did you enable `BUILD_PYTHON` in CMake and have this Python script in the right folder?')
Exception: Error: OpenPose library could not be found. Did you enable `BUILD_PYTHON` in CMake and have this Python script in the right folder?

FYI, my code is:

# Import Openpose (Windows/Ubuntu/OSX)
dir_path = os.path.dirname(os.path.realpath(__file__))
try:
    # Windows Import
    if platform == "win32":
        # Change these variables to point to the correct folder (Release/x64 etc.) 
        #sys.path.append(dir_path + '/../../python/openpose/Release');
        #os.environ['PATH']  = os.environ['PATH'] + ';' + dir_path + '/../../x64/Release;' +  dir_path + '/../../bin;'
        sys.path.append(dir_path + '\\..\\..\\python\\openpose\\Release');
        os.environ['PATH']  = os.environ['PATH'] + ';' + dir_path + '\\..\\..\\x64\\Release;' +  dir_path + '\\..\\..\\bin;'
        import openpose_python as op

I saw the definition of class WrapperPython in openpose/python/openpose/openpose_python.cpp. I have checked some tutorials of pybind11 to understand better on python API wrapping. In my understanding:

  1. pybind11 compiled openpose/python/openpose/openpose_python.cpp to generate openpose/build/python/openpose/Release/openpose_python.cp36-win_amd64.pyd.
  2. openpose/build/examples/tutorial_api_python/1_body_from_image.py can call the functions in openpose_python.cp36-win_amd64.pyd.

Did I miss anything? Or the files in build\python\openposeRelease are not complete?

I have also found there are some files in build\python\openpose\Debug. But the error is still the same after changing the path in 1_body_from_image.py to Debug.
img

P.S. Once succeeded, I would like to add two things in the installation documents for future reference:

  1. What files should we expect to see after a successful build in build\python\openposeRelease?
  2. How to solve AttributeError: module 'openpose_python' has no attribute 'WrapperPython'?

Thanks again for your great library and support.

It seems a bug was pushed to openpose. I will push a fix now, which will probably be accepted tmr.

Please use this branch for now:

https://github.com/CMU-Perceptual-Computing-Lab/openpose/pull/1020

or simply delete openpose_python.py

Fixed. Please, download the latest OpenPose. Best

Thanks for your high efficiency!

After I ran the example, the program stopped at

C:\Users\rosindigo\Documents\GitHub\openpose-master\openpose\build\examples\tutorial_api_python>python 1_body_from_image.py
Starting OpenPose Python Wrapper...

I modified the example code to

# Starting OpenPose
opWrapper = op.WrapperPython()
print('h')
print(params)
opWrapper.configure(params)
print('he')
opWrapper.start()
print('hello')

# Process Image
datum = op.Datum()
imageToProcess = cv2.imread(args[0].image_path)
datum.cvInputData = imageToProcess
opWrapper.emplaceAndPop([datum])

And found that the code stuck at opWrapper.configure(params)
img

The model path is correct, and there're model files in it.
img

Do you know what might cause this problem? Thanks again!

For future user's info, I did the whole installation from CMake GUI to VS 2015 build again:

  1. Clone openpose
  2. CMake GUI Configure (be sure to check BUILD_PYTHON after Configure & before Generate
    img
  3. CMake GUI Generate
  4. Build openpose in VS 2015
  5. Found pyd files in build/python/openpose/Debug
    img
  6. Modify the path in 1_body_from_image.py
    The example that works for me:
try:
    # Windows Import
    if platform == "win32":
        # Change these variables to point to the correct folder (Release/x64 etc.) 
        sys.path.append(dir_path + '/../../python/openpose/Debug');
        os.environ['PATH']  = os.environ['PATH'] + ';' + dir_path + '/../../x64/Debug;' +  dir_path + '/../../bin;'
  1. Run 1_body_from_image.py

After I follow the way that this issue discussed, I got same problem.

I used command "python 1_body_from_image.py".
I got oupput
"Starting OpenPose Python Wrapper..."
and then program crash.

For temporary use, I tried something and had a little progress.

I commented the configure code:

opWrapper = op.WrapperPython()
print('h')
print(params)
#opWrapper.configure(params)
print('he')
opWrapper.start()
print('hello')

then I can get this output saying no model files found:
img

Because the error shows that model filepath is just models/pose/..., so I copied models directory to openposebuild\examples\tutorial_api_python, then run again.

This time, the program seems to work:

C:\Users\rosindigo\Documents\GitHub\openpose-master\openpose\build\examples\tutorial_api_python>python 1_body_from_image.py
Starting OpenPose Python Wrapper...
h
{'model_folder': '../../../models/'}
he
Auto-detecting all available GPUs... Detected 1 GPU(s), using 1 of them starting at GPU 0.
hello
WARNING: Logging before InitGoogleLogging() is written to STDERR
I0116 11:37:58.915218  9748 common.cpp:36] System entropy source not available, using fallback algorithm to generate seed instead.
I0116 11:37:58.943364  9748 upgrade_proto.cpp:67] Attempting to upgrade input file specified using deprecated input fields: models\pose/body_25/pose_deploy.prototxt
I0116 11:37:58.943364  9748 upgrade_proto.cpp:70] Successfully upgraded file specified using deprecated input fields.
W0116 11:37:58.946336  9748 upgrade_proto.cpp:72] Note that future Caffe releases will only support input layers and not input fields.
I0116 11:37:58.948331  9748 net.cpp:51] Initializing net from parameters:
name: "OpenPose - BODY_25"
state {
  phase: TEST
  level: 0
}
layer {
  name: "input"
  type: "Input"
  top: "image"
  input_param {
    shape {
      dim: 1
      dim: 3
      dim: 16
      dim: 16
    }
  }
}

.......
.......
.......
I0116 11:38:00.943007  9748 net.cpp:200] pool1_stage1 does not need backward computation.
I0116 11:38:00.943007  9748 net.cpp:200] relu1_2 does not need backward computation.
I0116 11:38:00.943007  9748 net.cpp:200] conv1_2 does not need backward computation.
I0116 11:38:00.943007  9748 net.cpp:200] relu1_1 does not need backward computation.
I0116 11:38:00.943007  9748 net.cpp:200] conv1_1 does not need backward computation.
I0116 11:38:00.943007  9748 net.cpp:200] input does not need backward computation.
I0116 11:38:00.943007  9748 net.cpp:242] This network produces output net_output
I0116 11:38:00.944003  9748 net.cpp:255] Network initialization done.
I0116 11:38:01.111557  9748 net.cpp:744] Ignoring source layer image
I0116 11:38:01.111557  9748 net.cpp:744] Ignoring source layer vec_weight
I0116 11:38:01.113551  9748 net.cpp:744] Ignoring source layer vec_weight_vec_weight_0_split
I0116 11:38:01.113551  9748 net.cpp:744] Ignoring source layer heat_weight_vec_weight_1_split
I0116 11:38:01.113551  9748 net.cpp:744] Ignoring source layer label_heat
I0116 11:38:01.113551  9748 net.cpp:744] Ignoring source layer label_heat_label_heat_0_split
I0116 11:38:01.113551  9748 net.cpp:744] Ignoring source layer label_vec
I0116 11:38:01.113551  9748 net.cpp:744] Ignoring source layer label_vec_label_vec_0_split
I0116 11:38:01.123523  9748 net.cpp:744] Ignoring source layer Mconv7_stage0_L2_Mconv7_stage0_L2_0_split
I0116 11:38:01.125517  9748 net.cpp:744] Ignoring source layer weight_stage0_L2
I0116 11:38:01.125517  9748 net.cpp:744] Ignoring source layer loss_stage0_L2
I0116 11:38:01.130506  9748 net.cpp:744] Ignoring source layer Mconv7_stage1_L2_Mconv7_stage1_L2_0_split
I0116 11:38:01.130506  9748 net.cpp:744] Ignoring source layer weight_stage1_L2
I0116 11:38:01.130506  9748 net.cpp:744] Ignoring source layer loss_stage1_L2
I0116 11:38:01.136500  9748 net.cpp:744] Ignoring source layer Mconv7_stage2_L2_Mconv7_stage2_L2_0_split
I0116 11:38:01.138489  9748 net.cpp:744] Ignoring source layer weight_stage2_L2
I0116 11:38:01.138489  9748 net.cpp:744] Ignoring source layer loss_stage2_L2
I0116 11:38:01.143473  9748 net.cpp:744] Ignoring source layer weight_stage3_L2
I0116 11:38:01.143473  9748 net.cpp:744] Ignoring source layer loss_stage3_L2
I0116 11:38:01.146518  9748 net.cpp:744] Ignoring source layer Mconv7_stage0_L1_Mconv7_stage0_L1_0_split
I0116 11:38:01.146518  9748 net.cpp:744] Ignoring source layer weight_stage0_L1
I0116 11:38:01.146518  9748 net.cpp:744] Ignoring source layer loss_stage0_L1
I0116 11:38:01.155504  9748 net.cpp:744] Ignoring source layer weight_stage1_L1
I0116 11:38:01.155504  9748 net.cpp:744] Ignoring source layer loss_stage1_L1
F0116 11:38:02.985766  9748 syncedmem.cpp:71] Check failed: error == cudaSuccess (2 vs. 0)  out of memory
*** Check failure stack trace: ***

I checked my task manager, when the out-of-memory error shows, I still have memory left:
img

Hope someone could tell me how to handle this, I just want to successfully run the example so that I can proceed. Thanks!

You have not given enough information, please post a new issue using the template format and the exact commands run

Thanks! I opened #1026.

Why Don't Someone share build files, instead of re-inventing and building source code for python 3.6 windows?

Was this page helpful?
0 / 5 - 0 ratings