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.
Latest GitHub code
General configuration:
Non-default settings:
None
3rd-party software:
If GPU mode issue:
If Python API:
If Windows system:
compiled library
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