openpose icon indicating copy to clipboard operation
openpose copied to clipboard

ImportError: cannot import name 'pyopenpose' from partially initialized module 'openpose' (most likely due to a circular import)

Open AIHHU opened this issue 4 years ago • 15 comments

ImportError: cannot import name 'pyopenpose' from partially initialized module 'openpose' (most likely due to a circular import)

AIHHU avatar Jun 24 '20 13:06 AIHHU

Did you ever get this figured out? I'm having the same issue on OS X.

jayhendy avatar Jul 26 '20 23:07 jayhendy

Having the same issue.

hkair avatar Aug 30 '20 20:08 hkair

Same issue here, ubuntu 18.04. OpenPose was working previously, now something in the environment must have changed, and it no longer imports the module.

benrubin avatar Oct 11 '20 20:10 benrubin

Check /usr/local/python and see if there's a pyopenpose file in there. If yes, it means pyopenpose was installed outside of your openpose build folder. I suppose you are trying to run an example. The example is looking for pyopenpose under path/to/openpose/python. You can fix this by using the command cp /usr/local/python path/to/openpose

gordon-lim avatar Nov 16 '20 07:11 gordon-lim

cmake -DPYTHON_EXECUTABLE=~/anaconda3/bin/python3.8 -DPYTHON_LIBRARY=~/anaconda3/lib/libpython3.8.so. this work for me

CHDQ avatar Jan 12 '21 05:01 CHDQ

Hi, yes if you have a different version of python (not system python), then you may need to manually set those two parameters above. If you do sudo make install, then openpose get's installed to /usr/local/python and you simply need to add sys.path.append('/usr/local/python') in your code to import openpose

soulslicer avatar Feb 01 '21 17:02 soulslicer

same issue in windows 10. I built from source. Opened python and imported openpose and i got this error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\openpose\build\python\openpose\__init__.py", line 1, in <module> from . import pyopenpose as pyopenpose ImportError: cannot import name 'pyopenpose' from partially initialized module 'openpose' (most likely due to a circular import) (C:\openpose\build\python\openpose\__init__.py)

vishnumg avatar Feb 18 '21 15:02 vishnumg

On ubuntu 20.04.2 LTS, CPU only, built from source, I checked and make sure BUILD_PYHTON is flagged, openpose.bin works just fine.

If (from openpose dir) I run ls build/python/ CMakeFiles/ cmake_install.cmake Makefile openpose/ ls build/python/openpose/ CMakeFiles cmake_install.cmake __init__.py __init__.pyc Makefile __pycache__ pyopenpose.cpython-35m-x86_64-linux-gnu.so ls /usr/local/python/ openpose pyopenpose.cpython-35m-x86_64-linux-gnu.so ls /usr/local/python/openpose/ CMakeFiles __init__.py __pycache__ pyopenpose.cpython-35m-x86_64-linux-gnu.so

if just open the python3 console and run the following code:

Python 3.8.5 (default, Jan 27 2021, 15:41:15) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append('/usr/local/python')
>>> from openpose import pyopenpose as op
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/python/openpose/__init__.py", line 1, in <module>
    from . import pyopenpose as pyopenpose
ImportError: cannot import name 'pyopenpose' from partially initialized module 'openpose' (most likely due to a circular import) (/usr/local/python/openpose/__init__.py)

The same happens if I run sys.path.append('../../python') instead of sys.path.append('/usr/local/python')

NicoCatalano avatar Mar 10 '21 12:03 NicoCatalano

On ubuntu 20.04.2 LTS, CPU only, built from source, I checked and make sure BUILD_PYHTON is flagged, openpose.bin works just fine.

If (from openpose dir) I run ls build/python/ CMakeFiles/ cmake_install.cmake Makefile openpose/ ls build/python/openpose/ CMakeFiles cmake_install.cmake __init__.py __init__.pyc Makefile __pycache__ pyopenpose.cpython-35m-x86_64-linux-gnu.so ls /usr/local/python/ openpose pyopenpose.cpython-35m-x86_64-linux-gnu.so ls /usr/local/python/openpose/ CMakeFiles __init__.py __pycache__ pyopenpose.cpython-35m-x86_64-linux-gnu.so

if just open the python3 console and run the following code:

Python 3.8.5 (default, Jan 27 2021, 15:41:15) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append('/usr/local/python')
>>> from openpose import pyopenpose as op
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/python/openpose/__init__.py", line 1, in <module>
    from . import pyopenpose as pyopenpose
ImportError: cannot import name 'pyopenpose' from partially initialized module 'openpose' (most likely due to a circular import) (/usr/local/python/openpose/__init__.py)

The same happens if I run sys.path.append('../../python') instead of sys.path.append('/usr/local/python')

Solved it

Even if I don't have anaconda, by default the installer was creating the python file for python3.5 and not python3.8 . I had to force it setting PYTHON_EXECUTABLE to /usr/bin/python3 and PYTHON_LIBRARY to /usr/lib/python3.8/config-3.8-x86_64-linux-gnu/lib/libpython3.8.so in cmake-gui

NicoCatalano avatar Mar 10 '21 16:03 NicoCatalano

I am on MacOS BigSur and having the same problem. Can someone please update this thread if there is a solution available for this circular dependency issue.

viju85 avatar May 30 '21 02:05 viju85

On ubuntu 20.04.2 LTS, CPU only, built from source, I checked and make sure BUILD_PYHTON is flagged, openpose.bin works just fine. If (from openpose dir) I run ls build/python/ CMakeFiles/ cmake_install.cmake Makefile openpose/ ls build/python/openpose/ CMakeFiles cmake_install.cmake __init__.py __init__.pyc Makefile __pycache__ pyopenpose.cpython-35m-x86_64-linux-gnu.so ls /usr/local/python/ openpose pyopenpose.cpython-35m-x86_64-linux-gnu.so ls /usr/local/python/openpose/ CMakeFiles __init__.py __pycache__ pyopenpose.cpython-35m-x86_64-linux-gnu.so if just open the python3 console and run the following code:

Python 3.8.5 (default, Jan 27 2021, 15:41:15) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append('/usr/local/python')
>>> from openpose import pyopenpose as op
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/python/openpose/__init__.py", line 1, in <module>
    from . import pyopenpose as pyopenpose
ImportError: cannot import name 'pyopenpose' from partially initialized module 'openpose' (most likely due to a circular import) (/usr/local/python/openpose/__init__.py)

The same happens if I run sys.path.append('../../python') instead of sys.path.append('/usr/local/python')

Solved it

Even if I don't have anaconda, by default the installer was creating the python file for python3.5 and not python3.8 . I had to force it setting PYTHON_EXECUTABLE to /usr/bin/python3 and PYTHON_LIBRARY to /usr/lib/python3.8/config-3.8-x86_64-linux-gnu/lib/libpython3.8.so in cmake-gui

Worked after doing this, Thank you

pramod-wick avatar May 31 '21 13:05 pramod-wick

On ubuntu 20.04.2 LTS, CPU only, built from source, I checked and make sure BUILD_PYHTON is flagged, openpose.bin works just fine.

If (from openpose dir) I run ls build/python/ CMakeFiles/ cmake_install.cmake Makefile openpose/ ls build/python/openpose/ CMakeFiles cmake_install.cmake __init__.py __init__.pyc Makefile __pycache__ pyopenpose.cpython-35m-x86_64-linux-gnu.so ls /usr/local/python/ openpose pyopenpose.cpython-35m-x86_64-linux-gnu.so ls /usr/local/python/openpose/ CMakeFiles __init__.py __pycache__ pyopenpose.cpython-35m-x86_64-linux-gnu.so

if just open the python3 console and run the following code:

Python 3.8.5 (default, Jan 27 2021, 15:41:15) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append('/usr/local/python')
>>> from openpose import pyopenpose as op
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/python/openpose/__init__.py", line 1, in <module>
    from . import pyopenpose as pyopenpose
ImportError: cannot import name 'pyopenpose' from partially initialized module 'openpose' (most likely due to a circular import) (/usr/local/python/openpose/__init__.py)

The same happens if I run sys.path.append('../../python') instead of sys.path.append('/usr/local/python')

I do not have pyopenpose.cpython-35m-x86_64-linux-gnu.so file in my system, How can I have it?

senemaktas avatar Jul 13 '21 10:07 senemaktas

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 09 '22 06:01 stale[bot]

In my case, there was no file named "pyopenpose.so" in "/usr/local/python". Try below commands.

cd /usr/local/python/openpose
sudo ln -s pyopenpose.cpython-36m-x86_64-linux-gnu.so pyopenpose.so

(in this case, you should use sys.path.append('/usr/local/python') instead of sys.path.append('../../python'))

Eunho-J avatar Jul 18 '22 07:07 Eunho-J

Oh.. I didn’t even think about that solution. Thanks a lot for mail me.

2022년 8월 23일 (화) 오후 11:41, Kokilou @.***>님이 작성:

You are using conda environment, aren't you? I solved this question by using the environment when I cmake openpose.

— Reply to this email directly, view it on GitHub https://github.com/CMU-Perceptual-Computing-Lab/openpose/issues/1623#issuecomment-1224173170, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI3TL674DQIHI73WWRLJWYLV2TPIZANCNFSM4OGWAZ3Q . You are receiving this because you commented.Message ID: @.***>

Eunho-J avatar Aug 23 '22 14:08 Eunho-J