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

相關文章
相關標籤/搜索