Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ubuntu18.04] python3でopencv3を動かす #8

Closed
ShunjiHashimoto opened this issue Jul 31, 2021 · 7 comments
Closed

[ubuntu18.04] python3でopencv3を動かす #8

ShunjiHashimoto opened this issue Jul 31, 2021 · 7 comments

Comments

@ShunjiHashimoto
Copy link
Owner

No description provided.

@ShunjiHashimoto
Copy link
Owner Author

ShunjiHashimoto commented Jul 31, 2021

https://www.komee.org/entry/2018/10/26/120000
を参考に上から順番にinstall

pip3 install opencv-python

ModuleNotFoundError: No module named ‘skbuild’

というエラー発生

@ShunjiHashimoto
Copy link
Owner Author

pip または pip3が古い

@ShunjiHashimoto
Copy link
Owner Author

pip install -U pip 
# または
pip3 install -U pip

@ShunjiHashimoto
Copy link
Owner Author

ShunjiHashimoto commented Jul 31, 2021

hashimoto@desktop:~$ pip install --upgrade pip
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Requirement already up-to-date: pip in ./.local/lib/python2.7/site-packages (20.3.4)
hashimoto@desktop:~$ pip3 install opencv-python
Collecting opencv-python
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/01/9b/be08992293fb21faf35ab98e06924d7407fcfca89d89c5de65442631556a/opencv-python-4.5.3.56.tar.gz (89.2MB)
    100% |████████████████████████████████| 89.2MB 23kB/s 
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-0dtq6w64/opencv-python/setup.py", line 10, in <module>
        import skbuild
    ModuleNotFoundError: No module named 'skbuild'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-0dtq6w64/opencv-python/
hashimoto@desktop:~$ pip3 install opencv-python^C
hashimoto@desktop:~$ pip install -U pip
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Requirement already up-to-date: pip in ./.local/lib/python2.7/site-packages (20.3.4)
hashimoto@desktop:~$ pip3 install -U pip
Collecting pip
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/7c/02/9ab8b431aca1b46fcc1ac830a5870a28a12ba1abfa681904b1d2da876a86/pip-21.2.1-py3-none-any.whl (1.6MB)
    100% |████████████████████████████████| 1.6MB 42kB/s 
Installing collected packages: pip
Successfully installed pip-21.2.1
hashimoto@desktop:~$ pip3 install opencv-python
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
WARNING: Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /usr/local/lib/python3.6/dist-packages
sysconfig: /usr/lib/python3.6/site-packages
WARNING: Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /usr/local/lib/python3.6/dist-packages
sysconfig: /usr/lib/python3.6/site-packages
WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /usr/local/include/python3.6/UNKNOWN
sysconfig: /usr/include/python3.6m/UNKNOWN
WARNING: Value for scheme.scripts does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /usr/local/bin
sysconfig: /usr/bin
WARNING: Value for scheme.data does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /usr/local
sysconfig: /usr
WARNING: Additional context:
user = False
home = None
root = None
prefix = None
Defaulting to user installation because normal site-packages is not writeable
Collecting opencv-python
  Downloading opencv_python-4.5.3.56-cp36-cp36m-manylinux2014_x86_64.whl (49.9 MB)
     |████████████████████████████████| 49.9 MB 1.4 MB/s 
Collecting numpy>=1.13.3
  Downloading numpy-1.19.5-cp36-cp36m-manylinux2010_x86_64.whl (14.8 MB)
     |████████████████████████████████| 14.8 MB 1.9 MB/s 
Installing collected packages: numpy, opencv-python
  WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
  distutils: /home/hashimoto/.local/include/python3.6m/numpy
  sysconfig: /home/hashimoto/.local/include/python3.6/numpy
  WARNING: Additional context:
  user = True
  home = None
  root = None
  prefix = None
  WARNING: The scripts f2py, f2py3 and f2py3.6 are installed in '/home/hashimoto/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
  distutils: /home/hashimoto/.local/include/python3.6m/opencv-python
  sysconfig: /home/hashimoto/.local/include/python3.6/opencv-python
WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /home/hashimoto/.local/include/python3.6m/UNKNOWN
sysconfig: /home/hashimoto/.local/include/python3.6/UNKNOWN
Successfully installed numpy-1.19.5 opencv-python-4.5.3.56
hashimoto@desktop:~$ pip3 install -U pip^C
hashimoto@desktop:~$ ^C
hashimoto@desktop:~$ pip3 install opencv-contrib-python
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
WARNING: Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /usr/local/lib/python3.6/dist-packages
sysconfig: /usr/lib/python3.6/site-packages
WARNING: Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /usr/local/lib/python3.6/dist-packages
sysconfig: /usr/lib/python3.6/site-packages
WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /usr/local/include/python3.6/UNKNOWN
sysconfig: /usr/include/python3.6m/UNKNOWN
WARNING: Value for scheme.scripts does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /usr/local/bin
sysconfig: /usr/bin
WARNING: Value for scheme.data does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /usr/local
sysconfig: /usr
WARNING: Additional context:
user = False
home = None
root = None
prefix = None
Defaulting to user installation because normal site-packages is not writeable
Collecting opencv-contrib-python
  Downloading opencv_contrib_python-4.5.3.56-cp36-cp36m-manylinux2014_x86_64.whl (56.1 MB)
     |████████████████████████████████| 56.1 MB 569 kB/s 
Requirement already satisfied: numpy>=1.13.3 in ./.local/lib/python3.6/site-packages (from opencv-contrib-python) (1.19.5)
Installing collected packages: opencv-contrib-python
  WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
  distutils: /home/hashimoto/.local/include/python3.6m/opencv-contrib-python
  sysconfig: /home/hashimoto/.local/include/python3.6/opencv-contrib-python
  WARNING: Additional context:
  user = True
  home = None
  root = None
  prefix = None
WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /home/hashimoto/.local/include/python3.6m/UNKNOWN
sysconfig: /home/hashimoto/.local/include/python3.6/UNKNOWN
Successfully installed opencv-contrib-python-4.5.3.56
hashimoto@desktop:~$ python3
Python 3.6.9 (default, Jan 26 2021, 15:33:00) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.5.3'
>>> 

@ShunjiHashimoto
Copy link
Owner Author

ShunjiHashimoto commented Jul 31, 2021

エラーその2

hashimoto@desktop:~/catkin_ws/src/cugo$ rosrun cugo_detection human_detection.py 
^C^C^C/home/hashimoto/catkin_ws/src/cugo/cugo_detection/scripts/human_detection.py: 行 5: 予期しないトークン `cv2.__version__' 周辺に構文エラーがあります
/home/hashimoto/catkin_ws/src/cugo/cugo_detection/scripts/human_detection.py: 行 5: `print(cv2.__version__)'

@ShunjiHashimoto
Copy link
Owner Author

#!/usr/bin/env python を忘れていた

#!/usr/bin/env python
import numpy as np
import cv2, matplotlib
import matplotlib.pyplot as plt

print(cv2.__version__)

@ShunjiHashimoto
Copy link
Owner Author

hashimoto@desktop:~/catkin_ws/src/cugo$ rosrun cugo_detection human_detection.py 
3.2.0

@ShunjiHashimoto ShunjiHashimoto changed the title python3でopencv3を動かす [ubuntu18.04]python3でopencv3を動かす Jul 31, 2021
@ShunjiHashimoto ShunjiHashimoto changed the title [ubuntu18.04]python3でopencv3を動かす [ubuntu18.04] python3でopencv3を動かす Jul 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant