ubuntu---记录.重装电脑之设置电脑信息

(1)设置网络
(2)安装一个中文输入法
(3)CUDA+驱动+cuDNN+添加到系统环境中
(4)禁止内核更新
(5)安装好opencv之后,查看安装的版本
(6)查看自带的python版本
(7)设置系统里python的默认版本
(8)配python-opencv
(9)不管是用pip装什么模块,前面尽量不要加sudo
(10) Ubuntu16.04内核更新,导致驱动丢失
(11)ubuntu16.04 修改配置文件 禁止系统自动更新
(12)ubuntu16.04 + virtualenv + py2.7 + tf15.0 + keras2.2.4 + opencv2.4.9 +Numpy1.14
(13)使用虚拟机Virtualenv
(14)卸载opencv4.1.1.26重配置opencv2.4.9
(15)安装contrib包的几种方式

@20190906


-----------------------------------------------------------------------------------
(1)设置网络。设置IP,保证能上网。192.168.1.191255.255.255.0192.168.1.1
-----------------------------------------------------------------------------------
(2)安装一个中文输入法,方便日常工作。@https://blog.csdn.net/suifenghahahaha/article/details/78723733 ,Ubuntu 16.04安装iBus中文输入法pinyin及问题,能用就行,也不一定非要搜狗输入法。
-----------------------------------------------------------------------------------
(3)CUDA+驱动+cuDNN+添加到系统环境中
-----------------------------------------------------------------------------------
(4)禁止内核更新
查看内核:sudo dpkg --get-selections  |  grep  'linux'
...
linux-generic-hwe-16.04                install
linux-headers-4.15.0-45                install
linux-headers-4.15.0-45-generic            install
linux-headers-generic-hwe-16.04            install
linux-image-4.15.0-45-generic            install
linux-image-generic-hwe-16.04            install
linux-libc-dev:amd64                install
linux-modules-4.15.0-45-generic            install
linux-modules-extra-4.15.0-45-generic        install
linux-signed-generic-hwe-16.04            install
linux-sound-base                install

执行:
sudo apt-mark hold linux-headers-4.15.0-45 \
linux-headers-4.15.0-45-generic \
linux-image-4.15.0-45-generic \
linux-modules-4.15.0-45-generic \
linux-modules-extra-4.15.0-45-generic

echo "linux-headers-4.15.0-45 hold" | dpkg --set-selections
echo "linux-headers-4.15.0-45-generic hold" | dpkg --set-selections
echo "linux-image-4.15.0-45-generic hold" | dpkg --set-selections
echo "linux-modules-4.15.0-45-generic hold" | dpkg --set-selections
echo "linux-modules-extra-4.15.0-45-generic hold" | dpkg --set-selections

-----------------------------------------------------------------------------------5)安装好opencv之后,查看安装的版本
pkg-config --modversion opencv

u@u160406:~$ pkg-config --modversion opencv
3.4.2

-----------------------------------------------------------------------------------6)查看自带的python版本
u@u160406:~$ python
Python 2.7.12 (default, Nov 12 2018, 14:36:49) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
u@u160406:~$ python3
Python 3.5.2 (default, Nov 12 2018, 13:43:14) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
u@u160406:~$ 

-----------------------------------------------------------------------------------7)设置系统里python的默认版本
    显示说明,python默认的是Python 2.7.12,但还存在Python 3.5.2。
    接着,可以罗列出所有可用的 python 替代版本信息:
    update-alternatives --list python
    提示:update-alternatives: error: no alternatives for python
    如果出现以上所示的错误信息,则表示 Python 的替代版本尚未被 update-alternatives 命令识别。
    想解决这个问题,需要更新一下替代列表,将 python2.7 和 python3.5 放入其中。打开终端分别输入下面两条命令:
    $ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1
    $ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2
    #sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
    #sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
    然后再终端输入:
    python
    如果无误,此时python版本应该切换到默认的python3了。

    如果需要重新切换python版本,只需要在终端输入:
    sudo update-alternatives --config python
    然后选者你需要的python版本,输入序号回车即可。

  查看默认版本
    python --version
  上述命令中因为我们设置 /usr/bin/python3.5 设置的优先级为2 所以update-alternatives命令自己设置3.5为默认。再次显示Python代替版本信息:
    update-alternatives --list python
  切换版本:
    update-alternatives --config python


  移除替代版本,一旦系统中不再存在某个 Python 的替代版本时,我们可以将其从 update-alternatives 列表中删除掉。例如,我们可以将列表中的 python2.7 版本移除掉。
    wp@wp-MS-7519:~$ update-alternatives --remove python /usr/bin/python2.7
    update-alternatives: removing manually selected alternative - switching python to auto mode
    update-alternatives: using
    /usr/bin/python3.4 to provide
    /usr/bin/python (python)
    in auto mode

-----------------------------------------------------------------------------------
(8)配python-opencv
若无pip,先安装pip3,执行命令: sudo apt install python3-pip
安装依赖项,安装libopencv-dev依赖包,运行命令: sudo apt install libopencv-dev
安装opencv-python库
1. 直接安装最新版:sudo pip3 install opencv-python
2. 或者可以进行指定版本安装:pip3 install opencv_python==版本号
    由于我这里是安装opencv3.4.2,目前的最新版是3.4.2.16
    所以直接执行:pip3 install opencv_python==3.4.2.16

【备注,这一步的提前准备工作】
通常情况下,你的电脑里如果安装了python2.x也同时安装了python3.x,那么应该就会有两个pip。一个是pip2,另一个是pip3。好吧,可能还有一个既没有2,也米有3的pip,一般情况下,pip==pip2。
1、python下发现无pip,安装一个pip:  pip --version
The program 'pip' is currently not installed. You can install it by typing:
sudo apt install python-pip
py2执行:  sudo apt install python-pip
py3执行:  sudo apt install python3-pip


2、更新pip版本:
py2执行: pip install --upgrade pip  或者 python -m pip install --upgrade pip
py3执行: pip3 install --upgrade pip 或者 python3 -m pip install --upgrade pip

3、查看python版本:
pip --version
pip -V

4、问题解决
>>>>在默认py3下运行,会报错:
u@u160406:~$ pip -V
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name 'main'
u@u160406:~$ sudo gedit /usr/bin/pip

记得系统的默认py版本在执行相关的操作命令:
sudo gedit /usr/bin/pip3
//修改前
from pip import main
if __name__ == '__main__':
    sys.exit(main())
//修改后#@wp20190906 add
from pip import __main__
if __name__ == '__main__':  
    sys.exit(__main__._main())

在执行下列民令就不会报错了:
pip3 --version
pip3 -V

---------------------------python3安装opencv_python==3.4.2
u@u160406:~$ pip3 install opencv_python==3.4.2
Collecting opencv_python==3.4.2
  ERROR: Could not find a version that satisfies the requirement opencv_python==3.4.2 (from versions: 3.1.0.0, 3.1.0.1, 3.1.0.2, 3.1.0.3, 3.1.0.4, 3.1.0.5, 3.2.0.6, 3.2.0.7, 3.2.0.8, 3.3.0.9, 3.3.0.10, 3.3.1.11, 3.4.0.12, 3.4.0.14, 3.4.1.15, 3.4.2.16, 3.4.2.17, 3.4.3.18, 3.4.4.19, 3.4.5.20, 4.0.0.21, 4.0.1.23, 4.0.1.24, 4.1.0.25, 4.1.1.26)
ERROR: No matching distribution found for opencv_python==3.4.2
u@u160406:~$ pip3 install opencv_python==3.4.2.16


ERROR: No matching distribution found for numpy>=1.11.1 (from opencv_python==3.4.2.16)
查看Numpy版本:
python3
import numpy
print numpy.__version__

pip show numpy 查看numpy版本;
pip install -U numpy==1.12.0,降低numpy的版本

执行: pip3 install numpy==1.9.3
报错: Consider using the `--user` option or check the permissions.
改执行: sudo pip3 install numpy==1.9.3  ????
...
Installing collected packages: numpy
Successfully installed numpy-1.17.1

执行: sudo pip3 install opencv_python==3.4.2.16
...
Successfully installed opencv-python-3.4.2.16

u@u160406:~$ python
Python 3.5.2 (default, Nov 12 2018, 13:43:14) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.4.2'
>>> 

---------------------------python2安装opencv_python==3.4.2
pip install opencv_python==3.4.2 不好用
python2 -m pip install opencv-python 不好用
pip install --user -U numpy 升级numpy的版本
然后查看python3的安装路径,打开终端输入: which python3 #查看python3的安装路径
pip install --user opencv_python==3.4.2
pip install --user opencv_python==3.4.2.17
...
Successfully installed opencv-python-3.4.2.17
u@u160406:~$ python
Python 2.7.12 (default, Nov 12 2018, 14:36:49) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.4.2'
>>> 


(9)不管是用pip装什么模块,前面尽量不要加sudo
sudo是linux系统管理指令,是允许系统管理员让普通用户执行一些或者全部的root命令的一个工具,如halt,reboot,su等等。这样不仅减少了root用户的登录 和管理时间,同样也提高了安全性。sudo不是对shell的一个代替,它是面向每个命令的。

python 通过pip安装程序包的时候提示:Consider using the `--user` option or check the permissions.
原因不明,解决方法:
1、通过pip install pandas --user 安装
2、通过pip install pandas --user pandas安装

(10) Ubuntu16.04内核更新,导致驱动丢失
【吐血重装n次,发现可以后,过几天又显示nvidia-smi 未找到命令。终于知道原因:Ubuntu16.04内核更新。重新更换成旧内核就行。开机界面 Advanced potion for Ubuntu 选择旧版本 】
u@u160406:~$ nvidia-smi
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

u@u160406:~$  cat /etc/issue
Ubuntu 16.04.6 LTS \n \l

u@u160406:~$ uname -r
4.15.0-60-generic
u@u160406:~$ 

禁止更新内核,需时间来验证
sudo apt-mark hold linux-image-x.xx.x-xx-generic
sudo apt-mark hold linux-image-extra-x.xx.x-xx-generic
实践证明,不好使。

(11)ubuntu16.04 修改配置文件 禁止系统自动更新
修改配置文件/etc/apt/apt.conf.d/10periodic 然后0是关闭,将所有值改为0
vim etc/apt/apt.conf.d/10periodic

APT::Periodic::Update-Package-Lists “0”;
APT::Periodic::Download-Upgradeable-Packages “0”;
APT::Periodic::AutocleanInterval “0”;

启用自动更新,要启用软件包的自动更新,需要编辑自动升级配置。举例:
进入' /etc/apt/apt.conf.d '目录,使用vim编辑配置文件' 20auto-upgrades '。
cd /etc/apt/apt.conf.d/
vim 20auto-upgrades

进行如下配置。
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "3";
APT::Periodic::Unattended-Upgrade "1";


(12)ubuntu16.04 + virtualenv + py2.7 + tf15.0 + keras2.2.4 + opencv2.4.9 +Numpy1.14
sudo pip install virtualenv -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

>>>>>
Looking in indexes: http://pypi.douban.com/simple/
Collecting virtualenv
  Downloading http://pypi.doubanio.com/packages/8b/12/8d4f45b8962b03ac9efefe5ed5053f6b29334d83e438b4fe379d21c0cb8e/virtualenv-16.7.5-py2.py3-none-any.whl (3.3MB)
     |████████████████████████████████| 3.3MB 2.5MB/s 
Installing collected packages: virtualenv
Successfully installed virtualenv-16.7.5

source bin/activate

pip install --upgrade tensorflow==1.5.0  //pip install tensorflow-gpu
    >>> import tensorflow as tf
    >>> hello = tf.constant('Hello, TensorFlow!')
    >>> session = tf.Session()
    >>> print session.run(hello)
or
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl
$ pip install TF_BINARY_URL


pip install keras==2.2.4

pip install python-opencv==2.4.9  //如果没有安装annaconda的话,貌似要把opencv-python换成python-opencv。
Collecting opencv-python==2.4.9

sudo apt-get install python-opencv
python -m pip install opencv-python==2.4.9
  ERROR: Could not find a version that satisfies the requirement opencv-python==2.4.9 (from versions: 3.1.0.0, 3.1.0.1, 3.1.0.2, 3.1.0.3, 3.1.0.4, 3.1.0.5, 3.2.0.6, 3.2.0.7, 3.2.0.8, 3.3.0.9, 3.3.0.10, 3.3.1.11, 3.4.0.12, 3.4.0.14, 3.4.1.15, 3.4.2.16, 3.4.2.17, 3.4.3.18, 3.4.4.19, 3.4.5.20, 3.4.6.27, 3.4.7.28, 4.0.0.21, 4.0.1.23, 4.0.1.24, 4.1.0.25, 4.1.1.26)
ERROR: No matching distribution found for opencv-python==2.4.9

python -m pip install opencv-python
pip install opencv-contrib-python

pip uninstall opencv-contrib-python-4.1.1.26

Installing collected packages: opencv-python
Successfully installed opencv-python-4.1.1.26
Successfully installed opencv-contrib-python-4.1.1.26

    python  
    >>>import cv2 
    >>>cv2.__version__   
    >>>import keras


python -m pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose
pip install numpy==1.14

  Found existing installation: numpy 1.16.5
    Uninstalling numpy-1.16.5:
      Successfully uninstalled numpy-1.16.5
Successfully installed numpy-1.14.0

    >>> from numpy import *
    >>> eye(4)

解决引入keras后出现的Using TensorFlow backend的错误,在引入头文件之后,加入
import os
os.environ['KERAS_BACKEND']='tensorflow'

(13)使用虚拟机Virtualenv
启动虚拟环境
cd [虚拟环境名称]/
source bin/activate
...
退出虚拟环境: deactivate

(14)卸载opencv4.1.1.26重配置opencv2.4.9
pip uninstall opencv-python
Uninstalling opencv-python-4.1.1.26:
  Would remove:
    /home/u/Virtualenv/py2/lib/python2.7/site-packages/cv2/*
    /home/u/Virtualenv/py2/lib/python2.7/site-packages/opencv_python-4.1.1.26.dist-info/*
Proceed (y/n)? y
  Successfully uninstalled opencv-python-4.1.1.26

wget -O opencv.zip https://github.com/Itseez/opencv/archive/2.4.9.zip  
wget -O opencv-3.3.0.zip https://github.com/opencv/opencv/archive/2.4.9.zip

wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/2.4.9.zip
wget -O opencv-3.3.0.zip https://github.com/opencv/opencv_contrib/archive/2.4.9.zip

cmake -D MAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=$VIRTUAL_ENV/local/ -D PYTHON_EXECUTABLE=$VIRTUAL_ENV/bin/python -D PYTHON_PACKAGES_PATH=$VIRTUAL_ENV/lib/python2.7/site-packages -D INSTALL_PYTHON_EXAMPLES=ON ..

cmake -D MAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/home/u/Virtualenv/py2/local/ -D PYTHON_EXECUTABLE=/home/u/Virtualenv/py2/bin/python -D PYTHON_PACKAGES_PATH=/home/u/Virtualenv/py2/lib/python2.7/site-packages -D INSTALL_PYTHON_EXAMPLES=ON ..

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/opencv3.4.2 ..
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/opencv2.4.9 ..

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/home/u/Virtualenv/py2/local/ -D PYTHON_EXECUTABLE=/home/u/Virtualenv/py2/bin/python -D PYTHON_PACKAGES_PATH=/home/u/Virtualenv/py2/lib/python2.7/site-packages ..
cmake .. -DCMAKE_BUILD_TYPE=Release -DCUDA_nppi_LIBRARY=true -DWITH_CUDA=OFF ..

make -j
sudo make install  

解决Using TensorFlow backend

在引入头文件之后,加入
import os
os.environ['KERAS_BACKEND']='tensorflow'


1. tk开发包: sudo apt-get install tk-dev
2. Python的tk模块:sudo apt-get install python-tk


wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/4.1.1.zip
wget -O opencv-3.3.0.zip https://github.com/opencv/opencv_contrib/archive/4.1.1.zip

wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.4.2.zip

wget https://github.com/opencv/opencv_contrib/archive/4.1.1.zip

可选安装依赖
sudo apt-get install libprotobuf-dev protobuf-compiler
sudo apt-get install libgoogle-glog-dev libgflags-dev
sudo apt-get install libgphoto2-dev libeigen3-dev libhdf5-dev doxygen

opencv源码文件夹与opencv_contrib源码文件夹在同一级目录
$ cd opencv
$ mkdir build
$ cd build

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/opencv4.1.1 -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -D OPENCV_GENERATE_PKGCONFIG=YES -D INSTALL_C_EXAMPLES=ON  ..

mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/opencv4.1.1 -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.1.1/modules ..

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local/opencv4.1.1 -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON-D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D OPENCV_EXTRA_MODULES_PATH=~/Dev/opencv_contrib-3.4.2/modules -D BUILD_EXAMPLES=ON ..

-- Found Threads: TRUE  
-- A library with BLAS API not found. Please specify library location.
-- LAPACK requires BLAS
-- A library with LAPACK API not found. Please specify library location.


$ make -j4
$ sudo make install
$ sudo ldconfig


-- A library with LAPACK API found.
-- Could NOT find JNI (missing:  JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) 

-- VTK is not found
-- Checking for module 'libavresample'
--   No package 'libavresample' found
-- Checking for module 'gstreamer-base-1.0'
--   No package 'gstreamer-base-1.0' found
-- Checking for module 'gstreamer-app-1.0'
--   No package 'gstreamer-app-1.0' found
-- Checking for module 'gstreamer-riff-1.0'
--   No package 'gstreamer-riff-1.0' found
-- Checking for module 'gstreamer-pbutils-1.0'
--   No package 'gstreamer-pbutils-1.0' found

sudo apt-get install libblas-dev liblapack-dev
sudo apt-get install java-1.7.0-openjdk-devel
python -m pip install vtk
python -m pip 
sudo apt-get -y install libavresample-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev


 sudo apt-get install libgt.......
 #少多少就加多少,报错一直安装,直到如下报错
  checking for module 'gstreamer-base-1.0'
--   package 'gstreamer-base-1.0' not found
-- checking for module 'gstreamer-video-1.0'
--   package 'gstreamer-video-1.0' not found
-- checking for module 'gstreamer-app-1.0'
--   package 'gstreamer-app-1.0' not found
-- checking for module 'gstreamer-riff-1.0'
--   package 'gstreamer-riff-1.0' not found
-- checking for module 'gstreamer-pbutils-1.0'
————————————————
sudo apt-get -y install libopencv-dev build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip --fix-missing

原文链接:https://blog.csdn.net/tengxing007/article/details/54380732

1.  looking for ccache --not found
sudo apt-get install ccache

4. no package 'gtk+-3.0 found'
sudo apt-get install build-essential libgtk-3-dev
    
ImportError: No module named numpy.distutils.core
解决方法:使用“pip install numpy”命令安装 numpy

问题二:

    -- No package 'gtk+-3.0' found

    $ sudo apt-get install libgtk-3-dev

问题三:

    --   No package 'gstreamer-base-1.0' found
     
    --   No package 'gstreamer-video-1.0' found
     
    --   No package 'gstreamer-app-1.0' found
     
    --   No package 'gstreamer-riff-1.0' found
     
    --   No package 'gstreamer-pbutils-1.0' found
     

    sudo apt-get -y install libgstreamer-plugins-base1.0-dev
    sudo apt-get -y install libgstreamer1.0-dev

问题四:

    --   No package 'libavresample' found
     
    --   No package 'libgphoto2' found
     

    $ sudo apt-get -y install libavresample-dev
    $ sudo apt-get -y install libgphoto2-dev

问题五:

    -- Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
    -- Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
    -- Could NOT find Atlas (missing:  Atlas_CBLAS_INCLUDE_DIR Atlas_CLAPACK_INCLUDE_DIR Atlas_CBLAS_LIBRARY Atlas_BLAS_LIBRARY Atlas_LAPACK_LIBRARY) 
    -- Could NOT find Doxygen (missing:  DOXYGEN_EXECUTABLE) 
    -- Could NOT find JNI (missing:  JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) 
    -- Could NOT find Matlab (missing:  MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN) 
    -- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file

    $ sudo apt-get install libopenblas-dev

问题六:

    -- Could NOT find Doxygen (missing:  DOXYGEN_EXECUTABLE) 
     

    $ sudo apt-get install doxygen

问题七:

-- Could NOT find JNI (missing:  JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) 

a.下载jdk-8u151-linux-x64.tar.gz到download目录
http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk8-downloads-2133151-zhs.html

b.安装jdk
    $ cd download/
    $ sudo mkdir /usr/local/java
    $ sudo tar zxvf jdk-8u151-linux-x64.tar.gz -C /usr/local/java
    $ sudo ln -s /usr/local/java/jdk1.8.0_151/ /usr/local/java/latest

c. 添加环境变量:
    $ sudo vim /etc/profile

加入如下内容:
    export JAVA_HOME=/usr/local/java/latest
    export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
    export PATH=$PATH:$JAVA_HOME/bin

执行
    $ source /etc/profile

进行更新。

没有报错的情况下,cmake成功后会出现

原文链接:https://blog.csdn.net/weixin_41896508/article/details/80795239

apt install libopenblas-base libopenblas-dev

$ make -j4
$ sudo make install
$ sudo ldconfig

然后添加环境变量PKG_CONFIG_PATH到~/.bashrc
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

export PKG_CONFIG_PATH=/usr/local/opencv4.1.1/lib/pkgconfig 
export LD_LIBRARY_PATH=/usr/local/opencv4.1.1/lib


------------------------------------------------
 (15)安装contrib包时有如下3种方式:
1、可从https://pypi.python.org/pypi/opencv-contrib-python去下载并安装。

2、到https://www.lfd.uci.edu/~gohlke/pythonlibs/去下载opencv_python‑3.3.1+contrib‑cp36‑cp36m‑win_amd64.whl。

3、contrib包的源代码地址:https://github.com/opencv/opencv_contrib也可自行编译。
-----------------------------------------------

 

posted on 2019-10-14 13:26  WP的烂笔头  阅读(409)  评论(0编辑  收藏  举报