CMU-Perceptual-Computing-Lab / openpose

OpenPose: Real-time multi-person keypoint detection library for body, face, hands, and foot estimation
https://cmu-perceptual-computing-lab.github.io/openpose
Other
30.81k stars 7.83k forks source link

No module named 'pyopenpose' #2064

Open JoshVStaden opened 2 years ago

JoshVStaden commented 2 years ago

Hi there. I am trying to install and run Openpose on Python. I followed all necessary steps and, when running the "openpose_python.py" file, I get the "No module named 'pyopenpose'" error. Could you kindly provide some assistance as to where I am going wrong?

OS: Windows 10 Python: 3.8.10 Visual Studio: 2019 CUDA: 11.1 CUDNN: 8.1

Thanks in advance, and kindly let me know if you would like me to provide any further details.

SunnyCowMilk commented 2 years ago

Bro,did you have solved this problem?I get the same problem.

JoshVStaden commented 2 years ago

Bro,did you have solved this problem?I get the same problem.

Unfortunately not yet. I've been recommended to try Mediapipe, I might try that out.

MatthijsBurgh commented 2 years ago

Try to locate the library file. And check if it is in the PYTHONPATH. If not you need to append the path, similar to https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/b6a19a023430450f99a167f0db801d88bfffd985/examples/tutorial_api_python/01_body_from_image.py#L20-L24

Of course adapt this to your situation.

pedro-jorge-00010001 commented 2 years ago

Try running it from comand line. That worked for me. Before that I was trying to run it from VS Code.

MarioCavero commented 2 years ago

Still not working for me. I did some prints, might be an environment variable error. I tried to change all the / for \\ (which is\ in the system).

The prints in code:

    try:
        print('os.path.dirname(os.path.realpath(__file__)) is : ', dir_path)

        # Change these variables to point to the correct folder (Release/x64 etc.)
        sys.path.append(dir_path + '/../bin/python/openpose/Release');
        print("Appended dirpath : ", dir_path + '/../bin/python/openpose/Release', "\n ")
        os.environ['PATH']  = os.environ['PATH'] + ';' + dir_path + '/../x64/Release;' +  dir_path + '/../bin;'
        print("\n PRINTING SYS.PATH \n", sys.path, "\n")
        print("\n PRINTING ENVIRONMENT.PATH \n", os.environ['PATH'], "\n")
        import pyopenpose as op
    except ImportError as e:
        print('Error: OpenPose library could not be found. Did you enable `BUILD_PYTHON` in CMake and have this Python script in the right folder?')
        raise e

The printing outputs:

C:\Users\HP\Desktop\openpose\openpose-1.7.0-binaries-win64-cpu-python3.7-flir-3d\openpose\python> py .\openpose_python.py
os.path.dirname(os.path.realpath(__file__)) is :  C:\Users\HP\Desktop\openpose\openpose-1.7.0-binaries-win64-cpu-python3.7-flir-3d\openpose\python
Appended dirpath :  C:\Users\HP\Desktop\openpose\openpose-1.7.0-binaries-win64-cpu-python3.7-flir-3d\openpose\python/../bin/python/openpose/Release

 PRINTING SYS.PATH
 ['C:\\Users\\HP\\Desktop\\openpose\\openpose-1.7.0-binaries-win64-cpu-python3.7-flir-3d\\openpose\\python', 'C:\\Users\\HP\\AppData\\Local\\Programs\\Python\\Python310\\python310.zip', 'C:\\Users\\HP\\AppData\\Local\\Programs\\Python\\Python310\\DLLs', 'C:\\Users\\HP\\AppData\\Local\\Programs\\Python\\Python310\\lib', 'C:\\Users\\HP\\AppData\\Local\\Programs\\Python\\Python310', 'C:\\Users\\HP\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages', 'C:\\Users\\HP\\Desktop\\openpose\\openpose-1.7.0-binaries-win64-cpu-python3.7-flir-3d\\openpose\\python/../bin/python/openpose/Release']

 PRINTING ENVIRONMENT.PATH
 C:\Users\HP\AppData\Local\Programs\Python\Python310\Lib\site-packages\cv2\../../x64/vc14/bin;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\windows\System32\OpenSSH\;C:\Users\HP\AppData\Local\Programs\Python\Python310\Scripts\;C:\Users\HP\AppData\Local\Programs\Python\Python310\;C:\Users\HP\AppData\Local\Microsoft\WindowsApps;;C:\Users\HP\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\HP\Desktop\openpose\openpose-1.7.0-binaries-win64-cpu-python3.7-flir-3d\openpose\python/../x64/Release;C:\Users\HP\Desktop\openpose\openpose-1.7.0-binaries-win64-cpu-python3.7-flir-3d\openpose\python/../bin;

Error: OpenPose library could not be found. Did you enable `BUILD_PYTHON` in CMake and have this Python script in the right folder?
No module named 'pyopenpose'

The paths seem to be added correctly (apart of the differences in \ and /)

C:\Users\HP\Desktop\openpose\openpose-1.7.0-binaries-win64-cpu-python3.7-flir-3d\openpose\python/../bin, but copying and pasting this in the url of the folder view (to navigate directly there), seems to be working fine.

MatthijsBurgh commented 2 years ago

Start by using os.path.join instead of slashes for the paths. Now the paths are just a mess

youngday commented 1 year ago

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. import sys first

import sys import numpy as np sys.path.append('/usr/local/python') from openpose import pyopenpose as op

rahulrouniyar commented 1 year ago

Error related to pyopenpose is due to parameter PYBIND11_INSTALL in file CMakeCache.txt which prevents building openpose in python. We need to set the paramater to ON so that pyopenpose can be built. You can follow steps defined in https://github.com/rahulrouniyar/OpenposeOnCollab. I have uploaded the code to run Openpose in google collab there.

RRRJJJ419 commented 11 months ago

與 pyopenpose 相關的錯誤是由於檔案 CMakeCache.txt 中的參數 PYBIND11_INSTALL 導致的,該參數阻止在 python 中建置 openpose。我們需要將參數設為 ON,以便可以建立 pyopenpose。 您可以按照https://github.com/rahulrouniyar/OpenposeOnCollab中定義的步驟進行操作。 我已經上傳了在 google collab 中運行 Openpose 的程式碼。

I entered the 'CMakeCache.txt' file and modified the 'PYBIND11_INSTALL' parameter to 'ON', but I still encountered errors related to 'pyopenpose'.

rahulrouniyar commented 11 months ago

Did you rebuild it in cmake after configuring PYBIND11_INSTALL ? i.e. "!cd openpose && cd build && cmake .. !cd openpose && cd build && make -jnproc" Can you share me the screenshot of result after running above command after configuring PYBIND11_INSTALL?

aha-h commented 4 months ago

https://blog.csdn.net/qq_44705642/article/details/138624637?spm=1001.2014.3001.5501 may help you.

rajeevinr commented 2 months ago

use alternating of openpose, my recommendation is to use mediapipe.