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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值