Openpose: How to set python version?

Created on 10 Jul 2018  路  6Comments  路  Source: CMU-Perceptual-Computing-Lab/openpose

My system is ubuntu16.04, and got python2.7 and python3.6

I set /usr/bin/python to python3.6. But after building openpose, it can only run by python2.
The 1_extract_pose.py demo will encounters error like below if run by python3:

Traceback (most recent call last):
  File "1_extract_pose.py", line 37, in <module>
    openpose = OpenPose(params)
NameError: name 'OpenPose' is not defined

Most helpful comment

I have found a solution for that problem. It works for me so here it go.
You need to import:
from openpose import openpose as op
And then use it as:
op.OpenPose(params)

I hope this help you!

All 6 comments

Yes having the same problem!

+1

As per the instructions, you need to set your PYTHONPATH to where OpenPose python is built. If you ran sudo make install, it'll install by default to /usr/local/python, so you would add this to your environmental variables:

export PYTHONPATH=/usr/local/python/:$PYTHONPATH

If you are on Ubuntu or OSX, you can add this to your .bashrc

I have found a solution for that problem. It works for me so here it go.
You need to import:
from openpose import openpose as op
And then use it as:
op.OpenPose(params)

I hope this help you!

I run 'sudo make install' and openpose is installed in /usr/local/python/ directory.
I also add the path as PYTHONPATH in ~/.bashrc file, and source it.
However, my python code still can not import OpenPose. Besides, the demo code in build/example/python_tutorial can execute well.

I add the openpose/build/python/openpose or openpose/build/python/ path by sys.path.append, and still didn't work.
@soulslicer

I replace export PYTHONPATH=/usr/local/python/:$PYTHONPATH by export PYTHONPATH=/usr/local/python/openpose:$PYTHONPATH.
And problem solved!

Was this page helpful?
0 / 5 - 0 ratings