Is there any direct command to install pyopenpose? - python

I am trying to use Openpose from windows and i need to run .py file. But i couldn't find any command to install pyopenpose module So where can I find pyopenpose module?
I tried this command on cmd:
C:\openpose\examples\tutorial_api_python>python 01_body_from_image.py
I get the error :
Error: OpenPose library could not be found. Did you enable `BUILD_PYTHON` in CMake and have this Python script in the right folder?
Traceback (most recent call last):
File "01_body_from_image.py", line 26, in <module>
raise e
File "01_body_from_image.py", line 17, in <module>
import pyopenpose as op
ModuleNotFoundError: No module named 'pyopenpose'

The error in general is that PyOpenPose cannot be found (an error similar to: ImportError: cannot import name pyopenpose). Ensure first that BUILD_PYTHON flag is set to ON. If the error persists, check the following:
In the script you are running, check for the following line, and run the following command in the same location as where the file is.
Ubuntu/OSX:
sys.path.append('../../python');
ls ../../python/openpose
Check the contents of this location. It should contain one of the following files:
pyopenpose.cpython-35m-x86_64-linux-gnu.so
pyopenpose.so
If you do not have any one of those, you may not have compiled openpose successfully, or you may be running the examples, not from the build folder but the source folder. If you have the first one, you have compiled PyOpenPose for Python 3, and have to run the scripts with python3, and vice versa for the 2nd one. Follow the testing examples above for exact commands.
Windows:
Problem 1: If you are in Windows, and you fail to install the required third party Python libraries, it might print an error similar to: Exception: Error: OpenPose library could not be found. Did you enable BUILD_PYTHON in CMake and have this Python script in the right folder?. From GitHub issue #941:
I had a similar issue with Visual Studio (VS). I am pretty sure that the issue is that while you are compiling OpenPose in VS, 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 could not, but I had cv2 installed in a IPython environment (Anaconda), so I activated that environment, and then ran (change this to adapt it to your VS version and location of OpenPose.sln):
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild.exe
C:\path\to\OpenPose.sln
Problem 2: Python for Openpose needs to be compiled in Release mode for now. This can be done in Visual Studio. Once that is done check this line:
sys.path.append(dir_path + '/../../python/openpose/Release');
dir ../../python/openpose/Release
Check the contents of this location. It should contain one of the following files:
pyopenpose.cp36-win_amd64.pyd
pyopenpose.pyd
If such a folder does not exist, you need to compile in Release mode as seen above. If you have the first one, you have compiled PyOpenPose for Python 3, and have to run the scripts with python3, and vice versa for the 2nd one. Follow the testing examples above for exact commands. If that still does not work, check this line:
os.environ['PATH'] = os.environ['PATH'] + ';' + dir_path + '/../../x64/Release;' + dir_path + '/../../bin;'
dir ../../x64/Release
dir ../../bin
Ensure that both of these paths exist, as PyOpenPose needs to reference those libraries. If they don't exist, change the path so that they point to the correct location in your build folder.

Related

ImportError: cannot import name 'input_reader_pb2'

working on win10 64-bit
when i trying to train my model by E:\projectx\model-master\models-master>python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_pets.config
this error appear
File "train.py", line 49, in
from object_detection.builders import dataset_builder
File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\builders\dataset_builder.py",
line 27, in
from object_detection.data_decoders import tf_example_decoder
File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\data_decoders\tf_example_decoder.py",
line 27, in
from object_detection.protos import input_reader_pb2
ImportError: cannot import name 'input_reader_pb2'
i do run protoc 3.4 protoc object_detection/protos/*.proto --python_out=.
but the error still exist
i check all thing and it is should be fine and work, it is going me mad!!
please help....
thanks
As you already compiled all .proto files in object_detection/protos/ . You should see python files which have '_pb2' like eval_pb2. If you can see these then go to models/research directory and run these code one by one:
python setup.py build
python setup.py install
From inside the object_detection folder:
protoc ../object_detection/protos/*.proto --python_out=.
This command will generate a *_pb2.py for each .proto file in the object_detection/protos/ folder.
Note: Is important to specify a path above object_detection, otherwise errors would occur, most likely:
object_detection/protos/ssd_anchor_generator.proto: File not found.
protos/anchor_generator.proto:8:1: Import "object_detection/protos/ssd_anchor_generator.proto" was not found or had errors.
protos/anchor_generator.proto:17:5: "FlexibleGridAnchorGenerator" is not defined.
If the error persists probably you are in the wrong folder, take a look at the output message to see from where it is trying to import the file and execute the command in the right directory.
As last resort: Download the object_detection module from https://github.com/tensorflow/models/tree/master/research
place it in your working directory, enter it and re-execute the command above.
It will surely works as local modules have import priority over sys.path.
If not, the error message would be probably different from the one reported and the problem lies on the tensorflow installation or the protobuf compiler; as here where the problem was caused by the protoc version.
other useful links: https://github.com/tensorflow/models/issues/5264
Maybe you haven't added module slim to PYTHONPATH.It can be done by running below code inside models/research directory.
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
Seems that you didnt compile protobuf.
For solving it:
Download the latest protoc exe here: https://github.com/google/protobuf/releases (in your case should be win32)
Rename that folder to "protoc"
Put that folder inside models/research
in models/research via console, launch:
protoc/bin/protoc object_detection/protos/*.proto --python_out=.
I dont know exactly if that command will work on windows, but you have to be sure that you are using the protoc compiler that you downloaded (v.3.6) instead of the protoc in your enviroment.

ImportError: No module named _analog_swig

I am having issues getting python to import the _analog_swig gnuradio module in order to run gnuradio code on a Windows 8.1 64bit machine.
Some background: I am running Python 2.7.10 (installed in C:\Python27) and have installed the latest gnuradio binary (v3.7.11.1/v1.3 64-Bit Any CPU) from here: http://www.gcndevelopment.com/gnuradio/downloads.htm. I have installed gnuradio to C:\Program Files\GNURadio-3.7 .
I can run gnuradio companion and run flowgraphs from GRC successfully (which calls "C:\Program Files\GNURadio-3.7\bin\run_gr.bat" gnuradio-companion.py).
I have added & verified the following system variables are set:
Path: C:\Program Files\GNURadio-3.7\bin
PYTHONPATH: C:\Program Files\GNURadio-3.7\lib\site-packages
GRC_BLOCKS_PATH: C:\Program Files\GNURadio-3.7\share\gnuradio\grc\blocks
Now to the problem: If I run e.g. CMD and type:
python C:\test\top_block.py
I am returned the following ImportError:
File "C:\test\top_block.py", line 22, in <module>
from gnuradio import analog
File "C:\Program Files\GNURadio-3.7\lib\site-packages\gnuradio\analog\__init__.py", line 33, in <module>
from analog_swig import *
File "C:\Program Files\GNURadio-3.7\lib\site-packages\gnuradio\analog\analog_swig.py", line 17, in <module>
_analog_swig = swig_import_helper()
File "C:\Program Files\GNURadio-3.7\lib\site-packages\gnuradio\analog\analog_swig.py", line 16, in swig_import_helper
return importlib.import_module('_analog_swig')
File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named _analog_swig
The folder content of C:\Program Files\GNURadio-3.7\lib\site-packages\gnuradio\analog is as follows:
Comparing this to the folder content on a linux machine, which has a working install of gnuradio that works with python as I want it:
The difference seems to be that the folder in windows contains only a _analog_swig.pyc file, whereas the folder in linux contains a _analog_swig_.so file.
Any idea why the _analog_swig module can apparently not be imported in windows?
My plan is to be able to run gnuradio code directly from my python interpreter and being able to create compiled gnuradio executables so any help on how this could be fixed is much appreciated.
I've been struggling with this for the past few days, but I finally figured it out. I was trying to run GnuRadio Companion generated code in IDLE and also in PyCharm. I kept failing miserably with this same error. I finally figured it out:
-As Flexo says, the PYD file (_analog_swig.pyd) is actually a Windows DLL. The error makes it sound like Python is not finding that file, but that is not at all what was happening. The PYD file, being a DLL, has dependencies itself. Python is able to find _analog_swig.pyd just fine, but it could not find the DEPENDENCIES of that library.
-To verify if that's what wrong in your installation, download and use DependencyWalker (Google it) to check if your system can find the dependencies to _analog_swig.pyd.
-The fix for me was to add the GnuRadio-3.7/bin folder to my PATH environment variable. Inside that folder are a number of DLLs that the _analog_swig.pyd library needs to load. If you don't have the folder in your PATH, the module will fail to load in Python and throw the error you see above.
-I see that you verified that this folder is in your PATH, so this is apparently not the same problem, although your symptoms are exactly the same as mine. i.e. the GRC code would run just fine when you start with "run_gr.bat", but not when you run from a normal CMD window.
Hopefully that helps someone else that wants to use GNURadio Python code on Windows.
Friend,
As you mentioned, the GNU Companion calls \bin\run_gr.bat gnuradio-companion.py. That batch script does quite a bit of work on windows environment variables (try opening it in a text editor if you're curious).
In a sense, the run_gr.bat script puts together a temporary, custom python workspace for gnuradio so it can import anything it needs. It receives python scripts to run in this environment as command line arguments; hence, you can use it to run any GNU radio python code you want in your windows command prompt. Generally, you would call
<gnuradio_install_path>\bin\run_gr.bat <gnu_radio_code>.py
To test your import, you can try
# test.py
from gnuradio import analog
try calling the following from the command prompt, in the test.py directory:
<gnuradio_install_path>\bin\run_gr.bat test.py

Python module import failure in Jenkins

I have a project I'm trying to test and run on Jenkins. On my machine it works fine, but when I try to run it in Jenkins, it fails to find a module in the workspace.
In the main workspace directory, I run the command:
python xtests/app_verify_auto.py
And get the error:
+ python /home/tomcat7/.jenkins/jobs/exit103/workspace/xtests/app_verify_auto.py
Traceback (most recent call last):
File "/home/tomcat7/.jenkins/jobs/exit103/workspace/xtests/app_verify_auto.py", line 19, in <module>
import exit103.data.db as db
ImportError: No module named exit103.data.db
Build step 'Execute shell' marked build as failure
Finished: FAILURE
The directory exit103/data exists in the workspace and is a correct path, but python can't seem to find it.
This error exists both with and without virtualenv.
It's may caused by your PATH setting not right in jenkins environment.In fact , the environments for your default user and jenkins-user are not the same.
You may try to find what are the PATH and PYTHONPATH in your jenkins-user environments .
Try to run "shell commands" in jenkins "echo $path" and so on to see what's them are.
In most of time , you need to set the PATH by yourself.
You may reference this answer.
Jenkins: putting my Python module on the PYTHONPATH
Faced the same issue.
For others who are reading this, Run the build in your master node. It fixed the problem for me.
Running the build in the slave node doesn't give proper access to all the python modules and other commands such as jq to the workspace.

ImportError: No module named stack

I have a code in python that I have been working on and it builds and runs very well on my pc (Windows). I had to run the same code on my other machine which runs ubuntu,so I had to install all the packages on prior to runing the code. The problem is I ran into this error which I couldn't figure out. The error is triggered by one of the installed packages.
from qalsadi import analex
File "/usr/local/lib/python2.7/dist-packages/qalsadi/analex.py", line 14, in <module>
import pyarabic.araby as araby # basic arabic text functions
File "/usr/local/lib/python2.7/dist-packages/pyarabic/araby.py", line 28, in <module>
from stack import *
ImportError: No module named stack
I used the following command, "sudo pip install pyarabic", to install it. However, still the file stack.py doesn't exist among it's files. I searched in the folder /usr/local/lib/python2.7/dist-packages/pyarabic. The folder contains the following: araby.py and init.py and the coresponding pyc files only. I'v insalled and uninstalled it a number of times using "pip" but still the file is not there.
Check your pyarabic folder. Usually it's in Python27\Lib\site-packages\pyarabic.
There, there should be stack.py. If it doesn't exists, re-download pyarabic and then reinstall it.
After installation of pyarabic import STACK in this manner:
from pyarabic.stack import Stack
for window users
open cmd prompt and type the following to install the stack variable to python 3.x-
pip install pyarabic
To install and run with this code-
from pyarabic.stack import Stack
It seems like stack is not part of the Python Package Index so most probably it is a script you installed manually. The problem can be that the folder containing stack.py is not on your PYTHONPATH.
Open a terminal (Ctrl+ Alt + t) and edit the .bashrc file:
sudo gedit ~/.bashrc
Add the following line:
export PYTHONPATH=$PYTHONPATH:/path/to/the/folder/of/your/module
where you should substitute the part after the : to the full path to the directory
where stack.py can be found.
I hope this helps.

Building opencv with mingw. Fails when I import cv2. DLL load failed. Looking for .dll, but I have .dll.a's

I'm trying to build OpenCV with MSYS / MinGW so I can use the cv2 module in python.
I'm on Windows 7 64-bit and using 32 bit Python 2.7. Building OpenCV works, but I cannot seem to use it without getting an "ImportError: DLL load failed: The specified module could not be found." after importing cv2. I've been debugging it for awhile, and the common google solutions seem not to work.
These are the steps I have taken:
Removed all other instance of opencv from my computer (there were a few)
Built opencv with CMake and I manually set these flags:
'CMAKE_INSTALL_PREFIX' : 'C:/Program Files (x86)/OpenCV'
'CMAKE_BUILD_TYPE' : 'Release',
'CMAKE_C_FLAGS' : '-m32',
'CMAKE_CXX_FLAGS' : '-m32',
'BUILD_opencv_gpu' : False,
'BUILD_opencv_gpuarithm' : False,
'BUILD_opencv_gpubgsegm' : False,
'BUILD_opencv_gpucodec' : False,
'BUILD_opencv_gpufeatures2d' : False,
'BUILD_opencv_gpufilters' : False,
'BUILD_opencv_gpuimgproc' : False,
'BUILD_opencv_gpuoptflow' : False,
'BUILD_opencv_gpustereo' : False,
'BUILD_opencv_gpuwarping' : False
I do a cmake -G "MSYS Makefiles" ..., make -j9, and finally a make install. The printouts show that the libraries go where I expect them to.
My PATH includes
C:\MinGW\bin
C:\MinGW\msys\1.0\bin
C:\MinGW\libexec\gcc\mingw32\4.6.2
C:\Python27\
C:\Python27\Scripts
C:\Program Files (x86)\OpenCV
C:\Program Files (x86)\OpenCV\lib
My PYTHONPATH includes
C:\Python27\Lib\site-packages
C:\Python27
I then copy
cv2.pyd and libcv2.dll.a from C:\Python\Lib\site-packages
all libopencv_*249.dll.a from C:\Program Files (x86)\OpenCV\lib
libgcc_s_dw2-1.dll libstdc++-6.dll from C:\MinGW\bin
I MOVE ALL OF THESE into a directory I named cv2
In the cv2 directory I made an __init__.py file containing the following code:
import os, sys
from os.path import realpath, dirname
tpl_cv2 = realpath(dirname(__file__))
print(tpl_cv2)
sys.path.insert(0,tpl_cv2)
os.environ['PATH'] = tpl_cv2 + os.pathsep + os.environ['PATH']
try:
from cv2 import *
except Exception as ex:
print(repr(ex))
print(os.environ['PATH'])
print(sys.path)
raise
I then open a IPython terminal and enter the command "import cv2"
And I get the error: ImportError('DLL load failed: The specified module could not be found.',)
To debug this I've:
I load up the cv2.pyd file in depends.exe It shows that
LIBOPENCV_CALIB3D249.DLL and all the other opencv libs are not found. However, these are all in the same directory as cv2.pyd as well as in both the PATH and PYTHONPATH.
But they are named .dll.a because I compiled with MSYS / MinGW. I don't understand why its looking for the .dll without the .a suffix. I think this probably has something to do with the error, but I don't know where to go from here.
I've also built a small C++ application which reads and image using the OpenCV that I've built. It builds just fine, but I get the error: The program can't start because libopencv_core249.dll is missing from your computer. So, I'm more convinced this .dll.a thing is the issue.
I've tried simply renaming the libs from .dll.a to .dll, but that didn't work.
I'm hoping someone can shed light on this issue.
I feel really stupid. The dlls were in "C:\Program Files (x86)\bin" not "C:\Program Files (x86)\lib" It seems to work now.
This post helped me a lot. The answer I found was to make sure the compiled bin files were part of my PATH variable.
My CMAKE_INSTALL_PREFIX was C:\opencv\src\build\install
and adding C:\opencv\src\build\install\x86\vc11\bin to my PATH variable made cv2 start working.
Just to make sure other users can be helped with this answer:
Imagine you have compiled OpenCV and have several *.dll and the cv2.pyd file.
You need to copy those files to 'DLLs' folder within the python directory.
Then import the module to check wether it is ok.
I have also copied the *.lib files into the appropriate folder.
Best regards.

Categories