centos7最小化安装,python画图(各类报错解决)

本人在Windows下安装vmware,最小化安装了centos7,而后用putty ssh登陆虚拟机。没想到各类报错,折腾了一天。记录一下。
用python画图,固然要安装画图包了。先安装了pip,而后用pip安装matplotlibhtml

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脚本以下: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()

然而再一次报错!!!mysql

_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
图片描述linux

相关文章
相关标签/搜索