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

发布时间:2019-08-05 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了centos7最小化安装,python画图(各种报错解决)脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

本人在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 1millionnMySQL max_connection is 500nthe 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

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

脚本宝典总结

以上是脚本宝典为你收集整理的centos7最小化安装,python画图(各种报错解决)全部内容,希望文章能够帮你解决centos7最小化安装,python画图(各种报错解决)所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。