本人在Windows下安装vmware,最小化安装了centos7,然后用putty ssh登录虚拟机。没想到各种报错,折腾了一天。记录一下。
用python画图,当然要安装画图包了。先安装了pip,然后用pip安装matplotlib
pip install matplotlib
报错:
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c _posixsubprocess.c -o build/temp.linux-x86_64-2.7/_posixsubprocess.o
_posixsubprocess.c:3:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Running setup.py clean for subprocess32
Failed to build subprocess32
只需要yum install python-devel就可以解决上述问题。参考本人笔记
python脚本如下:
#!/usr/bin/env python
#encoding:utf8
import matplotlib.pyplot as plt
import numpy as np
x = []
fh = file('./count_frequence.data')
for count in fh:
x.append(int(count))
mean = np.mean(x)
bins = np.arange(-10,550,1)
plt.hist(x,bins);
plt.xlabel('process num')
plt.ylabel('count')
plt.title('histogram of count')
plt.axvline(mean,color='g')
report = 'fork 5000 process insert 1million\nmysql max_connection is 500\nthe avarage connection num is '+str(mean)
plt.text(100, 820, report)
#plt.axis([-100,600,0,1000])
plt.grid(True)
plt.show()
然而再一次报错!!!
_tkinter.TclError: no display name and no $DISPLAY environment variable
然后就是各种百度。。。。
用putty实现SSH进入Ubuntu,图形远程操作这篇文章感觉有点用。最后我才发现,不用修改sshd的配置文件(要允许Linux主机上的SSH X转发,查看 /etc/ssh/sshd_config 文件,加入以下一行,
X11Forwrding yes,但是我的配置文件默认就有改行),
只需要在windows安装Xming,然后配置一下Xming和putty就可以了。
PuTTY + Xming 远程使用 Linux GUI
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。