❯ python get-pip.py 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. ##这里的版本安全提示不用理 Collecting pip<21.0 Using cached pip-20.3.4-py2.py3-none-any.whl (1.5 MB) Installing collected packages: pip Attempting uninstall: pip Found existing installation: pip 20.3.4 Uninstalling pip-20.3.4: Successfully uninstalled pip-20.3.4 Successfully installed pip-20.3.4 ❯ pip --version pip 20.3.4 from /home/ctf/anaconda3/envs/python2/lib/python2.7/site-packages/pip (python 2.7) ##这里可以看到安装成功了
先安装基础依赖
1 2 3 4 5 6
❯ sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff-dev libdc1394-22-dev [sudo] password for ctf: Reading package lists... Done Building dependency tree... Done Reading state information... Done E: Unable to locate package libdc1394-22-dev ##没有这个包也能照常装opencv
然后执行pip安装就行了
1 2 3 4 5 6 7 8 9 10 11 12 13 14
❯ pip install opencv-python Collecting opencv-python Using cached opencv-python-4.3.0.38.tar.gz (88.0 MB) Installing build dependencies ... done Getting requirements to build wheel ... error ERROR: Command errored out with exit status 1: command: /home/ctf/anaconda3/envs/python2/bin/python /home/ctf/anaconda3/envs/python2/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpdbouGZ ##这里可能会报错Getting requirements to build wheel ..,因为默认安装最新版本的opnecv ❯ pip install opencv-python==4.1.1.26 ##安装其他版本的就可以,pyhton2.7不兼容高版本 Collecting opencv-python==4.1.1.26 Using cached opencv_python-4.1.1.26-cp27-cp27mu-manylinux1_x86_64.whl (28.7 MB) Collecting numpy>=1.11.1 Using cached numpy-1.16.6-cp27-cp27mu-manylinux1_x86_64.whl (17.0 MB) Installing collected packages: numpy, opencv-python Successfully installed numpy-1.16.6 opencv-python-4.1.1.26