Open apiszcz opened 7 years ago
@apiszcz look at https://github.com/gudovskiy/yoloNCS/issues/1
Solution for this issue was to uninstall opencv-python with pip3 Working! Thank you for all the work on YoloNCS
1down voteaccepted | I had exactly the same problem. OpenCV was installed from the sources. The difference between Python 2 and 3 environment was, that for Python 3 opencv-python was additionally installed via pip3. Apip3 uninstall opencv-pythonsolved it in my case. |
---|
@apiszcz thank you.
Finally, I solved this problem by the following two step:
1) Following this web mentioned OPTION 2, install OPENCV by source code.
2) Replaced the compiled .so dynamic library with the one that comes with opencv-python python3 package:
sudo cp <path to opencv source repo>/build/lib/python3/cv2.cpython-35m-x86_64-linux-gnu.so /usr/local/lib/python3.5/dist-packages/cv2/cv2.cpython-35m-x86_64-linux-gnu.so
Hope it can help you.
Hey, I followed the link to install opencv from source. While executing sample examples, it is working well for C++ and Java example but it shows "No module named cv2" for the Python example. Can anyone please help me with this.
Thanks!
the opencv installation does not appear to be in your path for PYTHON. PYTHONLIB is one way to add it.
On Thu, Dec 28, 2017 at 1:51 AM, Mashrin Srivastava < notifications@github.com> wrote:
Hey, I followed the link to install opencv from source. While executing sample examples, it is working well for C++ and Java example but it shows "No module named cv2" for the Python example. Can anyone please help me with this.
Thanks!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gudovskiy/yoloNCS/issues/4#issuecomment-354239226, or mute the thread https://github.com/notifications/unsubscribe-auth/ABXVTWaHq3zRwi56ReXY2sPKexso5AZMks5tEzqMgaJpZM4QJ5Md .
@apiszcz thanks a lot for your reply. I copied the cv2.so and cv2.py file from /usr/local/lib/python2.7/dist-packages to /usr/local/lib/python2.7/site-packages and added- export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages to ~/.bashrc and now it is getting imported in python2.
But I am still not being able to run it for python3 and when I repeated the same step to add the cv2.so and cv2.py to the python3.6/site-packages and again adding a PYTHON path for it similarly, in bashrc. But now, on importing cv2 in python3, I am getting a Segmentation fault error. Let me know if you have any suggestions regarding this.
Thanks!
After a reboot, I am getting this error while importing cv2 using python3
Traceback (most recent call last):
File "
Those error messages that you are using Python 2.7 you need to install python 3.5
On Dec 28, 2017 11:25 AM, "Mashrin Srivastava" notifications@github.com wrote:
After a reboot, I am getting this error while importing cv2 using python3
Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/site-packages/cv2/init.py", line 7, in from . import cv2 ImportError: /usr/local/lib/python2.7/site-packages/cv2/cv2.so: undefined symbol: PyCObject_Type
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gudovskiy/yoloNCS/issues/4#issuecomment-354314919, or mute the thread https://github.com/notifications/unsubscribe-auth/ABXVTbJ0Qb1h-xNG0zj-rKm7WXPuoz3Dks5tE8D6gaJpZM4QJ5Md .
I already have python 3.5 as well as python 3.6 installed.
Search path is incorrect
File "/usr/local/lib/python2.7/site-packages/cv2/init.py", line 7, in
On Thu, Dec 28, 2017 at 1:39 PM, Mashrin Srivastava < notifications@github.com> wrote:
I already have python 3.5 as well as python 3.6 installed.
On Thu, Dec 28, 2017 at 10:03 PM, apiszcz notifications@github.com wrote:
Those error messages that you are using Python 2.7 you need to install python 3.5
On Dec 28, 2017 11:25 AM, "Mashrin Srivastava" <notifications@github.com
wrote:
After a reboot, I am getting this error while importing cv2 using python3
Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/site-packages/cv2/init.py", line 7, in from . import cv2 ImportError: /usr/local/lib/python2.7/site-packages/cv2/cv2.so: undefined symbol: PyCObject_Type
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <https://github.com/gudovskiy/yoloNCS/issues/4#issuecomment-354314919 , or mute the thread https://github.com/notifications/unsubscribe- auth/ABXVTbJ0Qb1h-xNG0zj- rKm7WXPuoz3Dks5tE8D6gaJpZM4QJ5Md
.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gudovskiy/yoloNCS/issues/4#issuecomment-354316240, or mute the thread https://github.com/notifications/unsubscribe-auth/AQFh3t4vCQovvfkPyJz- aifz7PZTyYc2ks5tE8LtgaJpZM4QJ5Md .
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gudovskiy/yoloNCS/issues/4#issuecomment-354334414, or mute the thread https://github.com/notifications/unsubscribe-auth/ABXVTWRjsgKrZWLKBU8cOn45LEn26caHks5tE-BIgaJpZM4QJ5Md .
I have already made the changes in bashrc. I just copied the cv2.so and cv2.py from python 2.7 to python 3.5 and python 3.6 And then added those path to the bashrc as well. Now, when I try to run it, I am just getting segmentation fault (Nothing else except this)
On 29-Dec-2017 12:11 AM, "apiszcz" notifications@github.com wrote:
Search path is incorrect
File "/usr/local/lib/python2.7/site-packages/cv2/init.py", line 7, in
On Thu, Dec 28, 2017 at 1:39 PM, Mashrin Srivastava < notifications@github.com> wrote:
I already have python 3.5 as well as python 3.6 installed.
On Thu, Dec 28, 2017 at 10:03 PM, apiszcz notifications@github.com wrote:
Those error messages that you are using Python 2.7 you need to install python 3.5
On Dec 28, 2017 11:25 AM, "Mashrin Srivastava" < notifications@github.com
wrote:
After a reboot, I am getting this error while importing cv2 using python3
Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/site-packages/cv2/init.py", line 7, in from . import cv2 ImportError: /usr/local/lib/python2.7/site-packages/cv2/cv2.so: undefined symbol: PyCObject_Type
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <https://github.com/gudovskiy/yoloNCS/issues/4#issuecomment- 354314919 , or mute the thread https://github.com/notifications/unsubscribe- auth/ABXVTbJ0Qb1h-xNG0zj- rKm7WXPuoz3Dks5tE8D6gaJpZM4QJ5Md
.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/gudovskiy/yoloNCS/issues/4#issuecomment-354316240 , or mute the thread https://github.com/notifications/unsubscribe- auth/AQFh3t4vCQovvfkPyJz- aifz7PZTyYc2ks5tE8LtgaJpZM4QJ5Md .
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gudovskiy/yoloNCS/issues/4#issuecomment-354334414, or mute the thread https://github.com/notifications/unsubscribe-auth/ ABXVTWRjsgKrZWLKBU8cOn45LEn26caHks5tE-BIgaJpZM4QJ5Md .
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gudovskiy/yoloNCS/issues/4#issuecomment-354334781, or mute the thread https://github.com/notifications/unsubscribe-auth/AQFh3isy02gP6WMJFMy6pvkQK16b-DU3ks5tE-DugaJpZM4QJ5Md .
Do you think the existence of both python 3.5 and 3.6 can be a reason for this?
Output when importing using Python, Python 3.6 and 3.5: (Also, bashrc now doesn't have any PYTHONPATH to opencv except for Python2.
mashrin@mashrin:~$ python
Python 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:09:15)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import cv2
>>> quit()
mashrin@mashrin:~$ python3
Python 3.6.3 (default, Oct 3 2017, 21:45:48)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Segmentation fault (core dumped)
mashrin@mashrin:~$ python3.5
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/cv2/__init__.py", line 7, in <module>
from . import cv2
ImportError: /usr/local/lib/python2.7/site-packages/cv2/cv2.so: undefined symbol: PyCObject_Type
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ImportError: No module named 'apt_pkg'
Original exception was:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/cv2/__init__.py", line 7, in <module>
from . import cv2
ImportError: /usr/local/lib/python2.7/site-packages/cv2/cv2.so: undefined symbol: PyCObject_Type
>>> quit()
@zsy372901 on performing step 2 as mentioned by you, I am getting this.
cp: cannot stat '/home/mashrin/OpenCV/build/lib/python3/cv2.cpython-35m-x86_64-linux-gnu.so': No such file or directory
The entire installation was completed without any error and I am even able to import cv2 using python2 after coping the cv2.so and cv2.py to /usr/local/lib/python2.7/site-packages But, I am unable to import cv2 using python3. Also, I can't find cv2.cpython-35m-x86_64-linux-gnu.so anywhere. Kindly suggest.
The single image test works. This appears to be a video capture issue.
The object detection is producing a graph.LoadTensor error