opencv、jupyter安装
机器学习的相关环境
- 下载地址:https://sourceforge.net/projects/opencvlibrary/
- 参考资料:http://blog.csdn.net/u010128736/article/details/52713204
Python安装opencv
使用pip3安装,输入命令:
pip3 install opencv-python
1
2
3
4
5
6C:\Users\yangxuan>pip3 install opencv-python
Collecting opencv-python
Downloading opencv_python-3.2.0.7-cp35-cp35m-win_amd64.whl (22.2MB)
Requirement already satisfied: numpy>=1.11.1 in f:\python35\lib\site-packages (from opencv-python)
Installing collected packages: opencv-python
Successfully installed opencv-python-3.2.0.7测试一下
1
2
3
4
5
6
7import cv2
def opencv_test1():
img = cv2.imread("C:/Users/yangxuan/Desktop/Anne.png")
cv2.imshow("lena",img)
cv2.waitKey(10000)
pass
Python 安装 jupyter notebook
- 官网地址:https://jupyter.org/
使用pip3安装,输入命令:
pip3 install jupyter
1
2
3
4
5C:\Users\yangxuan>pip3 install jupyter
Collecting jupyter
Downloading jupyter-1.0.0-py2.py3-none-any.whl
Collecting ipykernel (from jupyter)
...运行,输入命令:
jupyter notebook
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15C:\Users\yangxuan>jupyter notebook
[I 12:02:55.955 NotebookApp] Writing notebook server cookie secret to C:\Users\yangxuan\AppData\Roam
ing\jupyter\runtime\notebook_cookie_secret
[I 12:02:56.164 NotebookApp] Serving notebooks from local directory: C:\Users\yangxuan
[I 12:02:56.164 NotebookApp] 0 active kernels
[I 12:02:56.165 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=fc8dfd
294977fac49f5b8bc23021d2557e372ab76df6c1ab
[I 12:02:56.165 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to s
kip confirmation).
[C 12:02:56.166 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=fc8dfd294977fac49f5b8bc23021d2557e372ab76df6c1ab
[I 12:02:57.382 NotebookApp] Accepting one-time-token-authenticated connection from ::1
指定 jupyter notebook 的启动目录
cd到对应的目录下,运行命令 jupyter notebook 即可,为了以后方便,制作一个windows的快捷脚本 startup_jupyter.bat
1
2
3h:
cd H:\Git_repository\z_mywiki\jupyter
jupyter notebook然后双击一下既可以启动
jupyter 上使用 matplotlib
直接运行 matplotlib 相关的代码不会在 jupyter 中绘制图案,需要先运行一次命令
%matplotlib inline
,才能显示出图案。(只需运行一次,后面多个代码段都无需运行,运行快捷键: Shift + Enter )测试一下代码:
1
2
3
4
5
6
7
8
9
10
11
12import os
import matplotlib.pyplot as plt
import numpy as np
def matplot_test1():
x = np.arange(20)
y = x**2
plt.plot(x, y)
plt.show()
pass
matplot_test1()