Ubuntu环境搭建 Python+pip+TensorFlow+Opencv+Minicoda

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/L_0000/article/details/80593589

Python安装

  • Python安装
sudo apt-get install python2.7
sudo apt-get install python3.6
  • Python测试
python -V
python --version

pip安装

sudo apt-get update
sudo apt-get install python-pip python-dev
  • pip测试
pip -V

TensorFlow安装

  • CPU
pip install tensorflow
pip3 install tensorflow
  • GPU
sudo pip install tensorflow-gpu
  • 镜像安装tensorflow
pip install \
  -i https://pypi.tuna.tsinghua.edu.cn/simple/ \
  https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/gpu/
  • Tensorflow测试
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

OpenCV安装

pip install --upgrade setuptools
pip install numpy Matplotlib
pip install opencv-python
  • OpenCV测试
#导入cv模块
import cv2 as cv
#读取图像,支持 bmp、jpg、png、tiff 等常用格式
img = cv.imread("D:\python\test.jpg")
#创建窗口并显示图像
cv.namedWindow("Image")
cv.imshow("Image",img)
cv.waitKey(0)
#释放窗口
cv2.destroyAllWindows() 

Minicoda安装安装

  • 下载miniocnda 的 bash 文件下载链接 https://conda.io/miniconda.html ,下载对应版本
  • 进入 Miniconda3-latest-Linux-x86_64.sh 所在目录,终端运行
  • $ bash Miniconda3-latest-Linux-x86_64.sh
  • 根据安装向导可以设置安装路径和环境变量,我选择默认设置,所以可以基本是傻瓜式安装
  • Minicoda测试
  • 打开终端
  • $conda --version

猜你喜欢

转载自blog.csdn.net/L_0000/article/details/80593589