centos7安装python3.6和python环境安装opencv

本系统为centos7,已安装python2.7。所以首先安装python3.6.2并重定向。本文使用pip安装opencv

1. 安装pip

$ wget https://bootstrap.pypa.io/get-pip.py

$ python get-pip.py

$ pip -V  #查看pip版本

参考:linux下安装pip

2.安装python3.6.2

首先安装依赖包

yum -y group install "Development tools"

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

下载Python3.6.2

wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz

安装Python3.6.2

mkdir /usr/local/python3

tar -xvf Python-3.6.2.tar.xz

cd Python-3.6.2

./configure --prefix=/usr/local/python3

make && make install


建立软链接

ln -s /usr/local/python3/bin/python3 /usr/bin/python

ln -s /usr/local/python3/bin/pip3 /usr/bin/pip

提示‘/usr/bin/python’: File exists

执行命令:

rm /usr/bin/python

参考:Centos7安装Python3的方法

3.安装opencv

执行如下pip命令安装opencv

pip install --upgrade setuptools

pip install numpy Matplotlib

pip install opencv-python

使用命令进入python,可以import安装opencv安装成功。

参考:Python环境搭建之OpenCV

你可能感兴趣的:(centos7安装python3.6和python环境安装opencv)