天飞 学习笔记


  • 首页

  • 关于

  • 标签

  • 分类

  • 归档

  • 公益404

  • 搜索

KDE5 konsole终端配置高亮当前tabbar

发表于 2018-04-10 | 更新于: 2019-11-08   |   更新于 2019-11-08

#环境

  • os: OpenSUSE Tumbleweed
  • pc: Apple macbook 13’ pro 2015

#故障描述
konsole默认的当前激活tab与非激活tab的区别不是很大,在一些切换的情况下很难一眼分辨出活动tab

#修复
配置活动tab的底色为绿色,字体加粗

在当前用户的home目录下的.config/konsolerc文件中的TabBar选项中添加如下配置

1
2
3
tianfei@openSuSeLinux:~> vi .config/konsolerc
[TabBar]
TabBarStyleSheet=QTabBar::tab { min-width: 2em ; max-width: 25em } QTabBar::tab:selected {font: bold; color: darkblue; background-color: yellowgreen}

还有一种方法是写入一个css文件中,新版本的konsole支持使用style文件,具体写法可参考kde官方文档
https://docs.kde.org/stable5/en/applications/konsole/tabbarstylsheet.html
如下图所示:

1
2
3
4
5
6
haotianfei@tianfei-opensuse:~/github/tianfei/talenhao.github.io.hexo/source/img> cat ~/bin/konsole.css
QTabBar::tab:selected {
background: yellowgreen;
font: bold;
color: darkblue
}

Firefox下载中文名文件为乱码的一种解决方法

发表于 2018-01-25 | 更新于: 2019-11-08   |   更新于 2019-11-08

#环境

  • os: OpenSUSE Tumbleweed
  • pc: Apple macbook 13’ pro 2015

#故障描述
从百度网盘直接下载的中文pdf文件显示为乱码,具体是显示url编码后的中文名

#修复
查看当前目录下的文件

1
2
3
4
5
6
7
tianfei@openSuSeLinux:~/Downloads/pdf> ll
total 61420
-rw-r--r-- 1 tianfei users 12848877 Jan 25 10:10 %5B%E7%91%9E%E5%85%B8%E5%8F%B2%28%E4%B8%8A%E4%B8%8B%E5%86%8C%29%5D.%28%E7%91%9E%E5%85%B8%29%E5%AE%89%E5%BE%B7%E7%94%9F.%E6%89%AB%E6%8F%8F%E7%89%88.pdf
-rw-r--r-- 1 tianfei users 6683784 Jan 12 14:52 Docker in Practice.pdf
-rw-r--r-- 1 tianfei users 283995 Jan 16 11:50 dotguide.pdf
-rw-r--r-- 1 tianfei users 0 Jan 23 11:35 %E6%9C%9D%E9%B2%9C%E7%AE%80%E5%8F%B2.pdf
-rw-r--r-- 1 tianfei users 43070424 Jan 19 17:38 亚洲历史 许海山.pdf

其中第一,四个pdf文件显示乱码,写了一个url解码脚本进行修复

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
(venv3.6) tianfei@openSuSeLinux:~/Downloads/pdf> cat ~/devops/ScriptsForTianfei/decode_urlcode_filename.py
#!/usr/bin/env python3
# -*- coding:UTF-8 -*-

import os
import urllib.parse


def convert_filename(files):
for file in files:
unquote_file_name = urllib.parse.unquote(file)
os.rename(file, unquote_file_name)


if __name__ == '__main__':
files = os.listdir()
convert_filename(files)

在当前目录下执行脚本之后,文件名显示正确的UTF-8格式

1
2
3
4
5
6
7
(venv3.6) tianfei@openSuSeLinux:~/Downloads/pdf> ll
total 61420
-rw-r--r-- 1 tianfei users 6683784 Jan 12 14:52 Docker in Practice.pdf
-rw-r--r-- 1 tianfei users 283995 Jan 16 11:50 dotguide.pdf
-rw-r--r-- 1 tianfei users 12848877 Jan 25 10:10 [瑞典史(上下册)].(瑞典)安德生.扫描版.pdf
-rw-r--r-- 1 tianfei users 43070424 Jan 19 17:38 亚洲历史 许海山.pdf
-rw-r--r-- 1 tianfei users 0 Jan 23 11:35 朝鲜简史.pdf

%5B%E7%91%9E%E5%85%B8%E5%8F%B2%28%E4%B8%8A%E4%B8%8B%E5%86%8C%29%5D.%28%E7%91%9E%E5%85%B8%29%E5%AE%89%E5%BE%B7%E7%94%9F.%E6%89%AB%E6%8F%8F%E7%89%88.pdf
显示为[瑞典史(上下册)].(瑞典)安德生.扫描版.pdf,%E6%9C%9D%E9%B2%9C%E7%AE%80%E5%8F%B2.pdf显示为朝鲜简史.pdf

脚本下载在我的github:

https://github.com/talenhao/ScriptsForTianfei/tree/master/decode_urlcode_filename

修复opensuse不能进入睡眠模式(suspend)

发表于 2018-01-18 | 更新于: 2019-11-08   |   更新于 2019-11-08

#环境

  • os: OpenSUSE Tumbleweed
  • pc: Apple macbook 13’ pro 2015

#故障描述
电源管理设置成合上屏进入睡眠模式,但发现笔记本从包里拿出来时很烫

#修复
查看当前唤醒的设备

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
tianfei@openSuSeLinux:~> cat /proc/acpi/wakeup 
Device S-state Status Sysfs node
PEG0 S3 *disabled
EC S3 *disabled platform:PNP0C09:00
HDEF S3 *disabled pci:0000:00:1b.0
RP01 S3 *disabled pci:0000:00:1c.0
RP02 S3 *disabled pci:0000:00:1c.1
RP03 S4 *disabled pci:0000:00:1c.2
ARPT S4 *enabled pci:0000:03:00.0
RP05 S3 *disabled pci:0000:00:1c.4
RP06 S3 *disabled pci:0000:00:1c.5
SPIT S3 *disabled spi:spi-APP000D:00
XHC1 S3 *enabled pci:0000:00:14.0
ADP1 S3 *disabled platform:ACPI0003:00
LID0 S3 *enabled platform:PNP0C0D:00

其中enable的是可执行唤醒的设备,S3 state是suspend的状态.
保留使用电源键及开屏唤醒

1
2
3
4
5
6
7
8
9
#
# disabling wakeup on USB --- use just PWRB
#
for device in XHC EHC1 EHC2; do
grep $device /proc/acpi/wakeup | grep enabled > /dev/null && {
echo Disabling wakeup on $device
echo $device > /proc/acpi/wakeup
}
done

将脚本内容放置在/etc/init.d/boot.local中就可以了.

参考:
https://askubuntu.com/questions/552345/can-not-suspend-my-laptop-asus

使用Monit替代supversor管理及监控服务小结

发表于 2017-09-28 | 更新于: 2019-11-08   |   更新于 2019-11-08

本来准备使用satl推送supervisor来着,研究了一下monit官方文档并试用了一下,这几天使用下来与supervisor对比感受.

Monit - utility for monitoring services on a Unix system

  1. 管理监控:
  • 管理:process,programs(任何脚本),files,directories,filesystems.
  • 监控处理:auto restart not run, auto restart not respond, stop when use too much resource, monitor change(timestamps, checksum, size, 内容), 网络检测(tcp/ip, socket, protocol(任何协议), ssl), system resources(cpu,mem,load,io,空间…)
  • 服务依赖: 依赖检测,顺序启动服务
  1. 日志及监控:
  • 支持记录日志到syslog或自己的日志文件
  • error判断规则自定义发送alert message
  1. web界面
  2. 语法

SYNOPSIS
monit [options]

两者的ctl脚本操作比较相似, monit不仅仅是个服务管理系统,资源监控也是相当丰富,比supervisor强大太多.

区别如下,如有错误,请指正:

monit supervisor
非常小,安装简单 只支持python2.4-2.7之间的版本,pip安装稍显复杂
c编写,无其它依赖 python编写,依赖其它第三方库
配置语法灵活,功能强大 功能一般,只能处理了进程
支持监控告警 不支持告警
非侵入 侵入式,需要supervisor启动,而且不支持daemoned
支持服务依赖 依赖支持不友好

monit 使用帮助

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
[root@web53 monit.d]# monit --help 
Usage: monit [options] {arguments}
Options are as follows:
-c file Use this control file
-d n Run as a daemon once per n seconds
-g name Set group name for start, stop, restart, monitor, unmonitor, status and summary
-l logfile Print log information to this file
-p pidfile Use this lock file in daemon mode
-s statefile Set the file monit should write state information to
-I Do not run in background (needed for run from init)
--id Print Monit's unique ID
--resetid Reset Monit's unique ID. Use with caution
-t Run syntax check for the control file
-v Verbose mode, work noisy (diagnostic output)
-vv Very verbose mode, same as -v plus log stacktrace on error
-H [filename] Print SHA1 and MD5 hashes of the file or of stdin if the
filename is omited; monit will exit afterwards
-V Print version number and patchlevel
-h Print this text
Optional action arguments for non-daemon mode are as follows:
start all - Start all services
start name - Only start the named service
stop all - Stop all services
stop name - Only stop the named service
restart all - Stop and start all services
restart name - Only restart the named service
monitor all - Enable monitoring of all services
monitor name - Only enable monitoring of the named service
unmonitor all - Disable monitoring of all services
unmonitor name - Only disable monitoring of the named service
reload - Reinitialize monit
status [name] - Print full status information for service(s)
summary [name] - Print short status information for service(s)
quit - Kill monit daemon process
validate - Check all services and start if not running
procmatch <pattern> - Test process matching pattern

(Action arguments operate on services defined in the control file)

当前系统进程

1
2
3
4
[graylog2@web53 bin]$ ps ux fww
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
graylog2 32286 0.0 0.0 108336 1908 pts/1 S 16:28 0:00 -bash
graylog2 2130 1.0 0.0 110200 1044 pts/1 R+ 21:53 0:00 \_ ps ux fww

配置monit的服务

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
[root@web53 monit.d]# cat *
check process elasticsearch with pidfile /data/graylog2/elasticsearch-5.6.1/bin/elasticsearch.pid
group elasticsearch
start program = "/bin/bash -c 'source /data/graylog2/.bash_profile ; cd /data/graylog2/elasticsearch-5.6.1/bin/; ./elasticsearch -d --pidfile /data/graylog2/elasticsearch-5.6.1/bin/elasticsearch.pid'"
as UID graylog2 and gid graylog2
with timeout 60 seconds
stop program = "/bin/bash -c 'kill -9 `cat /data/graylog2/elasticsearch-5.6.1/bin/elasticsearch.pid`'"
as UID graylog2 and gid graylog2
if failed
host 127.0.0.1 port 9200
then restart
check process graylog2 with pidfile /tmp/graylog.pid
group graylog2
start program = "/bin/bash -c 'source /data/graylog2/.bash_profile ; /data/graylog2/graylog-2.3.1/bin/graylogctl start -f /data/graylog2/graylog-2.3.1/graylog.conf -d'" as UID graylog2 with timeout 60 seconds
stop program = "/bin/bash -c 'source /data/graylog2/.bash_profile ; /data/graylog2/graylog-2.3.1/bin/graylogctl stop'" as UID graylog2
if failed
host 192.168.1.53 port 12345
then restart

check process mongodb with pidfile /data/graylog2/mongodb-linux-x86_64-3.4.9/bin/mongod.pid
group mongodb
start program = "/bin/bash -c 'source /data/graylog2/.bash_profile ; /data/graylog2/mongodb-linux-x86_64-3.4.9/bin/mongod --dbpath /data/graylog2/mongodb-linux-x86_64-3.4.9/db/ --pidfilepath /data/graylog2/mongodb-linux-x86_64-3.4.9/bin/mongod.pid --logpath /data/graylog2/mongodb-linux-x86_64-3.4.9/bin/mongodb.log'"
as UID graylog2 and gid graylog2
with timeout 60 seconds
stop program = "/bin/bash -c 'source /data/graylog2/.bash_profile ; /data/graylog2/mongodb-linux-x86_64-3.4.9/bin/mongod --shutdown --dbpath /data/graylog2/mongodb-linux-x86_64-3.4.9/db/'"
as UID graylog2 and gid graylog2
if failed
host 192.168.1.53 port 27017
then restart

启动monit管理服务

1
2
3
4
5
[graylog2@web53 bin]$ ps ux 
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
graylog2 6109 120 1.6 15419244 1114420 ? Sl 22:00 2:17 /data/graylog2/jdk1.8.0_144/bin/java -Djava.library.path=/data/graylog2/
graylog2 7246 2.0 0.0 110236 1144 pts/1 R+ 22:01 0:00 ps ux
graylog2 32286 0.0 0.0 108336 1908 pts/1 S 16:28 0:00 -bash

从日志上可以看出启动过程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[CST Sep 27 22:00:00] info     : Reinitializing monit daemon
[CST Sep 27 22:00:00] info : Awakened by the SIGHUP signal
Reinitializing Monit - Control file '/etc/monit.conf'
[CST Sep 27 22:00:00] info : Shutting down Monit HTTP server
[CST Sep 27 22:00:01] info : Monit HTTP server stopped
[CST Sep 27 22:00:01] error : Cannot translate 'web53' to FQDN name -- Name or service not known
[CST Sep 27 22:00:01] info : Starting Monit HTTP server at [0.0.0.0]:2812
[CST Sep 27 22:00:01] info : Monit HTTP server started
[CST Sep 27 22:00:01] info : 'web53' Monit reloaded
[CST Sep 27 22:00:01] error : 'graylog2' process is not running
[CST Sep 27 22:00:01] info : 'graylog2' trying to restart
[CST Sep 27 22:00:01] info : 'graylog2' start: /bin/bash
[CST Sep 27 22:01:05] info : 'graylog2' process is running with pid 6109
[CST Sep 27 22:02:05] error : 'graylog2' process is not running
[CST Sep 27 22:02:05] info : 'graylog2' trying to restart
[CST Sep 27 22:02:05] info : 'graylog2' start: /bin/bash
[CST Sep 28 14:55:21] error : 'elasticsearch' process is not running
[CST Sep 28 14:55:21] info : 'elasticsearch' trying to restart
[CST Sep 28 14:55:21] info : 'elasticsearch' start: /bin/bash
[CST Sep 28 14:56:24] info : 'elasticsearch' process is running with pid 4059
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
[root@web53 ~]# monit status
Cannot translate 'web53' to FQDN name -- Name or service not known
The Monit daemon 5.14 uptime: 17h 42m

Process 'mongodb'
status Running
monitoring status Monitored
pid 9674
parent pid 1
uid 507
effective uid 507
gid 0
uptime 3h 6m
children 0
memory 46.1 MB
memory total 46.1 MB
memory percent 0.0%
memory percent total 0.0%
cpu percent 0.0%
cpu percent total 0.0%
port response time 0.000s to [192.168.1.53]:27017 type TCP/IP protocol DEFAULT
data collected Thu, 28 Sep 2017 15:12:38

Process 'graylog2'
status Running
monitoring status Monitored
pid 31630
parent pid 1
uid 507
effective uid 507
gid 0
uptime 24m
children 0
memory 1.1 GB
memory total 1.1 GB
memory percent 1.7%
memory percent total 1.7%
cpu percent 0.0%
cpu percent total 0.0%
port response time 0.000s to [192.168.1.53]:12345 type TCP/IP protocol DEFAULT
data collected Thu, 28 Sep 2017 15:12:38

Process 'elasticsearch'
status Running
monitoring status Monitored
pid 4059
parent pid 1
uid 507
effective uid 507
gid 507
uptime 17m
children 0
memory 2.8 GB
memory total 2.8 GB
memory percent 4.5%
memory percent total 4.5%
cpu percent 0.0%
cpu percent total 0.0%
port response time 0.000s to [127.0.0.1]:9200 type TCP/IP protocol DEFAULT
data collected Thu, 28 Sep 2017 15:12:38

System 'web53'
status Running
monitoring status Monitored
load average [1.35] [1.32] [1.39]
cpu 5.2%us 1.0%sy 0.8%wa
memory usage 17.0 GB [27.0%]
swap usage 0 B [0.0%]
data collected Thu, 28 Sep 2017 15:12:38

manager page
process page

为什么wireshark抓取ethernet II前导8字符与FCS

发表于 2017-09-28 | 更新于: 2019-11-08   |   更新于 2019-11-08

今天使用wireshark抓取frame,对照帧格式发现wireshark抓取出的帧少了两个部分
如图:
红圈是目标地址,蓝圈是源地址,绿圈是类型(这是ehternet II区别802.3的地方,可以识别上层协议)
manager page

查找资料好觉得这篇文章说得很清楚明了
(http://blog.sina.com.cn/s/blog_5e8ca2db0100vopc.html)

在物理层上网卡要先去掉前导同步码和帧开始定界符,然后对帧进行CRC检验,如果帧校验和错,就丢弃此帧。如果校验和正确,就判断帧的目 的硬件地址是否符合自己的接收条件(目的地址是自己的物理硬件地址、广播地址、可接收的多播硬件地址等),如果符合,就将帧交“设备驱动程序”做进一步处 理。这时我们的抓包软件才能抓到数据,因此,抓包软件抓到的是去掉前导同步码、帧开始分界符、FCS之外的数据,

帧格式图,
manager page

参考:http://blog.sina.com.cn/s/blog_5e8ca2db0100vopc.html

supervisord 从入门到放弃

发表于 2017-09-27 | 更新于: 2019-11-08   |   更新于 2019-11-08

#supervisord 从入门到放弃

Supervisor 在在类UNIX系统上控制进程运行的一个应用.通过fock子进程的方式管理服务的运行,在服务stop时自动重启.
这几天简单试用了下supervisord,使用中发现几个问题:

  1. 只能支持非后台的进程(they should run in the foreground, not be daemons)
  2. 由于是fock的方式管理,只支持由supervisor自己启动的服务,对于已经在线运行的大量服务,不好意思,无法管理.(这个很蛋疼,现网那么多服务,总不能都重启一遍吧?!)
  3. 有些服务即使非后台运行,也无法正常操作成功.我试用了使用superviser启动graylog2,使用graylog2的前台运行graylogctl run运行服务.

supervisor对服务的侵入性(intrusive)硬伤,目前我用supervisor只能做些简单服务的管理.
下一步试下non-intrusive的monit.

sublime3光标移动快捷键自定义设置

发表于 2017-09-25 | 更新于: 2019-11-08   |   更新于 2019-11-08

在pycharm下setting-keymap下可以设置上下左右移动时的快捷键,
人个不太喜欢用上下左右键,手要离开中心区域.为了不冲突,使用shift+vim的移动快捷键设置
总是觉得pycharm太重型了,虽然我的笔记本是ssd硬盘,但每次启动时风扇总是运行一下.
在众多编辑器中选择了sublime3,安装一些python开发的插件.
sublime的设置跟pycharm有很大的不同,在proferences->key bindings,需要编辑配置文件,
不过还算简单,在从左侧的键盘移动键复制到右侧的user配置中,修改成

1
2
3
4
5
6
7
[
{ "keys": ["ctrl+h"], "command": "move", "args": {"by": "characters", "forward": false} },
{ "keys": ["ctrl+l"], "command": "move", "args": {"by": "characters", "forward": true} },
{ "keys": ["ctrl+k"], "command": "move", "args": {"by": "lines", "forward": false} },
{ "keys": ["ctrl+j"], "command": "move", "args": {"by": "lines", "forward": true} },

]

geymotion2.8 opensuse 启动报错处理

发表于 2017-09-20 | 更新于: 2019-11-08   |   更新于 2019-11-08

报错如下:

1
2
htf@linux-rzt3:~/bin/genymotion2.8/genymotion> ./genymotion
./genymotion: symbol lookup error: /usr/lib64/libX11.so.6: undefined symbol: xcb_wait_for_reply64

查找了https://stackoverflow.com/questions/40998027/genymotion-genymotion-symbol-lookup-error-usr-lib64-libgl-so-1-undefined
删除rm libxcb.so.1可行.
同时又报了drm的一个错误,相同 的方法解决

1
2
3
4
5
6
7
8
htf@linux-rzt3:~/bin/genymotion2.8/genymotion> rm libxcb.so.1
libxcb.so.1
htf@linux-rzt3:~/bin/genymotion2.8/genymotion> rm libdrm.so.2
libdrm.so.2
htf@linux-rzt3:~/bin/genymotion2.8/genymotion> ./genymotion
Logging activities to file: /home/htf/.Genymobile/genymotion.log
Logging activities to file: /home/htf/.Genymobile/genymotion.log
Logging activities to file: /home/htf/.Genymobile/Genymotion/deployed/Google Nexus 5 - 5.1.0 - API 22 - 1080x1920/genymotion-player.log

python3.6 networkx使用pygraphviz绘图报TypeError

发表于 2017-09-13 | 更新于: 2019-11-08   |   更新于 2019-11-08

报错如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Traceback (most recent call last):
File "/home/htf/pyproject/sce/ser_con_evo/serconevo/netgraph/__init__.py", line 139, in <module>
main()
File "/home/htf/pyproject/sce/ser_con_evo/serconevo/agent/service_collect_agent.py", line 97, in warper
func(*args, **kwargs)
File "/home/htf/pyproject/sce/ser_con_evo/serconevo/agent/service_collect_agent.py", line 320, in warper
fun(*args, **kwargs)
File "/home/htf/pyproject/sce/ser_con_evo/serconevo/agent/service_collect_agent.py", line 69, in warper
return func(*args, **kwargs)
File "/home/htf/pyproject/sce/ser_con_evo/serconevo/agent/service_collect_agent.py", line 88, in warper
func(*args, **kwargs)
File "/home/htf/pyproject/sce/ser_con_evo/serconevo/netgraph/__init__.py", line 124, in main
A.draw('pyv.png', format='png')
File "/home/htf/pyproject/sce/lib/python3.6/site-packages/pygraphviz/agraph.py", line 1474, in draw
data = self._run_prog(prog, args)
File "/home/htf/pyproject/sce/lib/python3.6/site-packages/pygraphviz/agraph.py", line 1338, in _run_prog
warnings.warn(b"".join(errors), RuntimeWarning)
TypeError: cannot use a string pattern on a bytes-like object

查了下使用的networkx版本,networkx (1.11),networkx在2.0版本才开始支持3.6,怀疑版本问题

NetworkX 2.0

Release date: TBD

Support for Python 3.6 added, drop support for Python 3.3.

1
2
3
4
5
6
7
8
9
10
11
12
13
(sce) htf@linux-rzt3:~/pyproject/sce/ser_con_evo/serconevo/netgraph> pip install networkx==2.0rc1
Collecting networkx==2.0rc1
Using cached networkx-2.0rc1.zip
Requirement already satisfied: decorator>=4.1.0 in /home/htf/pyproject/sce/lib/python3.6/site-packages (from networkx==2.0rc1)
Building wheels for collected packages: networkx
Running setup.py bdist_wheel for networkx ... done
Stored in directory: /home/htf/.cache/pip/wheels/c9/28/7a/00a40c74cd75194c6997fa7a58f99a6029f0dcb3f2d94ba0da
Successfully built networkx
Installing collected packages: networkx
Found existing installation: networkx 1.11
Uninstalling networkx-1.11:
Successfully uninstalled networkx-1.11
Successfully installed networkx-2.0rc1

升级完后发现还是报错,查看报错信息,觉得还是跟pygraphviz有关系,升级到最新的1.4rc1,升级进要指定一些参数.
默认–library-path获取到的为None,我手工指定路径

1
pip install pygraphviz==1.4rc1 --install-option="--include-path=/usr/include/graphviz" --install-option="--library-path=/usr/lib64/graphviz/

再次执行.成功出图.

pip_install_pygraphviz_cgraph.h_problem

发表于 2017-09-12 | 更新于: 2019-11-08   |   更新于 2019-11-08

pip 安装pygraphviz报出cgraph.h找不到的问题,ubuntu有pygraphviz-dev包,opensuse要使用pygraphviz-devel包

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
(v_python3.6) htf@linux-rzt3:/tmp> pip install pygraphviz
Collecting pygraphviz
Using cached pygraphviz-1.3.1.zip
Building wheels for collected packages: pygraphviz
Running setup.py bdist_wheel for pygraphviz ... error
Complete output from command /home/htf/.virtualenvs/v_python3.6/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-29gpsytb/pygraphviz/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpqyu0lzlwpip-wheel- --python-tag cp36:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/pygraphviz
copying pygraphviz/release.py -> build/lib.linux-x86_64-3.6/pygraphviz
copying pygraphviz/__init__.py -> build/lib.linux-x86_64-3.6/pygraphviz
copying pygraphviz/graphviz.py -> build/lib.linux-x86_64-3.6/pygraphviz
copying pygraphviz/agraph.py -> build/lib.linux-x86_64-3.6/pygraphviz
copying pygraphviz/version.py -> build/lib.linux-x86_64-3.6/pygraphviz
creating build/lib.linux-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_edge_attributes.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_string.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_subgraph.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_readwrite.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_clear.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_attribute_defaults.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_attributes.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_node_attributes.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_layout.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_graph.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/__init__.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_unicode.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_html.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
copying pygraphviz/tests/test_drawing.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
running egg_info
writing pygraphviz.egg-info/PKG-INFO
writing dependency_links to pygraphviz.egg-info/dependency_links.txt
writing top-level names to pygraphviz.egg-info/top_level.txt
reading manifest file 'pygraphviz.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching '*~' found anywhere in distribution
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '.svn' found anywhere in distribution
no previously-included directories found matching 'doc/build'
writing manifest file 'pygraphviz.egg-info/SOURCES.txt'
copying pygraphviz/graphviz.i -> build/lib.linux-x86_64-3.6/pygraphviz
copying pygraphviz/graphviz_wrap.c -> build/lib.linux-x86_64-3.6/pygraphviz
running build_ext
building 'pygraphviz._graphviz' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/pygraphviz
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -g -DOPENSSL_LOAD_CONF -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -g -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -g -fPIC -I/usr/include/python3.6m -c pygraphviz/graphviz_wrap.c -o build/temp.linux-x86_64-3.6/pygraphviz/graphviz_wrap.o
pygraphviz/graphviz_wrap.c:2954:10: fatal error: graphviz/cgraph.h: No such file or directory
#include "graphviz/cgraph.h"
^~~~~~~~~~~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1

----------------------------------------
Failed building wheel for pygraphviz
Running setup.py clean for pygraphviz
Failed to build pygraphviz
Installing collected packages: pygraphviz
Running setup.py install for pygraphviz ... error
Complete output from command /home/htf/.virtualenvs/v_python3.6/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-29gpsytb/pygraphviz/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-aiuj4thp-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/htf/.virtualenvs/v_python3.6/include/site/python3.6/pygraphviz:
running install
Trying pkg-config
Package libcgraph was not found in the pkg-config search path.
Perhaps you should add the directory containing `libcgraph.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libcgraph' found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-29gpsytb/pygraphviz/setup.py", line 87, in <module>
tests_require=['nose>=0.10.1', 'doctest-ignore-unicode>=0.1.0',],
File "/usr/lib64/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib64/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/pip-build-29gpsytb/pygraphviz/setup_commands.py", line 44, in modified_run
self.include_path, self.library_path = get_graphviz_dirs()
File "/tmp/pip-build-29gpsytb/pygraphviz/setup_extra.py", line 121, in get_graphviz_dirs
include_dirs, library_dirs = _pkg_config()
File "/tmp/pip-build-29gpsytb/pygraphviz/setup_extra.py", line 44, in _pkg_config
output = S.check_output(['pkg-config', '--libs-only-L', 'libcgraph'])
File "/usr/lib64/python3.6/subprocess.py", line 336, in check_output
**kwargs).stdout
File "/usr/lib64/python3.6/subprocess.py", line 418, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['pkg-config', '--libs-only-L', 'libcgraph']' returned non-zero exit status 1.

----------------------------------------
Command "/home/htf/.virtualenvs/v_python3.6/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-29gpsytb/pygraphviz/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-aiuj4thp-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/htf/.virtualenvs/v_python3.6/include/site/python3.6/pygraphviz" failed with error code 1 in /tmp/pip-build-29gpsytb/pygraphviz/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
(v_python3.6) htf@linux-rzt3:/tmp> sudo zypper install graphviz-devel
Retrieving repository 'tsinghua-packman' metadata ....................................................................................................................[done]
Building repository 'tsinghua-packman' cache .........................................................................................................................[done]
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following 56 NEW packages are going to be installed:
autoconf automake cairo-devel damageproto-devel fixesproto-devel fontconfig-devel freetype2-devel glib2-devel graphite2-devel graphviz-devel harfbuzz-devel kbproto-devel
libbz2-devel libcairo-script-interpreter2 libdrm-devel libexpat-devel libglvnd-devel libicu-devel libjpeg62-devel libLASi1 libLASi-devel libpcrecpp0 libpcreposix0
libpixman-1-0-devel libpng16-compat-devel libpng16-devel libstdc++6-devel-gcc7 libstdc++-devel libtool libX11-devel libXau-devel libxcb-devel libxcb-res0
libxcb-screensaver0 libxcb-xf86dri0 libxcb-xtest0 libxcb-xv0 libxcb-xvmc0 libXdamage-devel libXext-devel libXfixes-devel libXft-devel libXrender-devel libXxf86vm-devel
Mesa-libEGL-devel Mesa-libGL-devel pango-devel pcre-devel pthread-stubs-devel renderproto-devel tcl-devel tk-devel xextproto-devel xf86vidmodeproto-devel xproto-devel
zlib-devel

The following 2 recommended packages were automatically selected:
libpng16-compat-devel Mesa-libGL-devel

56 new packages to install.
Overall download size: 19.3 MiB. Already cached: 0 B. After the operation, additional 104.2 MiB will be used.
Continue? [y/n/...? shows all options] (y): y

再次安装成功

1
2
3
4
5
6
7
(sce) htf@linux-rzt3:~/pyproject/sce/ser_con_evo/pip_download> pip install pygraphviz-1.3.1.zip
Processing ./pygraphviz-1.3.1.zip
Requirement already satisfied (use --upgrade to upgrade): pygraphviz==1.3.1 from file:///home/htf/pyproject/sce/ser_con_evo/pip_download/pygraphviz-1.3.1.zip in /home/htf/pyproject/sce/lib/python3.6/site-packages
Building wheels for collected packages: pygraphviz
Running setup.py bdist_wheel for pygraphviz ... done
Stored in directory: /home/htf/.cache/pip/wheels/24/e7/76/6e3ea1649ae65c36eb23a62a319c15fcf568647c0cbe14966b
Successfully built pygraphviz
1…8910

天飞

95 日志
41 分类
79 标签
RSS
GitHub E-Mail
Links
  • 天飞的博客
© 2017 — 2020 天飞
由 Hexo 强力驱动
|
主题 — NexT.Gemini v5.1.4
本站访客数 人次 本站总访问量 次