首页 > python教程

详解python模块pychartdir安装及导入问题

时间:2020-12-09 python教程 查看: 730

在迁移别人写好的脚本时,发现pychartdir没有导入,脚本执行报错。以下是报错内容:

[modps@LGJF-ZYC5-MMSC-WEB02 ~]$ python /opt/aspire/product/modps/mopps/shell/dayreport_linux.py
/etc/host.conf: line 1: bad command `nospoof on'
Traceback (most recent call last):
 File "/opt/aspire/product/modps/mopps/shell/dayreport_linux.py", line 42, in <module>
 from pychartdir import *
ImportError: No module named pychartdir

之前使用的是pip来安装模块的,先安装下pip:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python get-pip.py

然后开始下载pychartdir模块:

[root@LGJF-ZYC5-MMSC-WEB02 ~]# pip install pychartdir
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
/etc/host.conf: line 1: bad command `nospoof on'
ERROR: Could not find a version that satisfies the requirement pychartdir (from versions: none)
ERROR: No matching distribution found for pychartdir

发现报错了,报错的大概意思为:未找到合适的版本。

那么就只好手动安装了

1.从官方地址下载python版本的ChartDirector并解压

https://www.advsofteng.com/download.html

# 使用lrzsz命令将下载的包传递到服务器上
[root@LGJF-ZYC5-MMSC-WEB02 ~]# tar -xf chartdir_python_linux_64.tar.gz

2.在python模块安装目录下(/usr/lib/python2.7/site-packages)创建一个chartdirector的目录

# 查看模块安装目录
[root@LGJF-ZYC5-MMSC-WEB02 ~]# python
Python 2.7.5 (default, May 3 2017, 07:55:04) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-14)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7/site-packages', '/usr/lib64/python2.7/site-packages/gtk-2.0', '/usr/lib/python2.7/site-packages']
>>> 
[root@LGJF-ZYC5-MMSC-WEB02 ~]# cd /usr/lib/python2.7/site-packages
[root@LGJF-ZYC5-MMSC-WEB02 site-packages]# mkdir chartdirector
[root@LGJF-ZYC5-MMSC-WEB02 site-packages]# cd chartdirector
[root@LGJF-ZYC5-MMSC-WEB02 chartdirector]# pwd
/usr/lib/python2.7/site-packages/chartdirector

3.进入解压好的Chartdirector/ lib,将其下面的内容拷贝到上边创建的目录下,同时在site-packages下创建一个chartdirector.pth,写入chartdirector到文件中:

[root@LGJF-ZYC5-MMSC-WEB02 chartdirector]# cd
[root@LGJF-ZYC5-MMSC-WEB02 ~]# cd ChartDirector/lib/
[root@LGJF-ZYC5-MMSC-WEB02 lib]# cp -a ./* /usr/lib/python2.7/site-packages/chartdirector/
[root@LGJF-ZYC5-MMSC-WEB02 lib]# cd /usr/lib/python2.7/site-packages/
[root@LGJF-ZYC5-MMSC-WEB02 site-packages]# cat chartdirector.pth
chartdirector

4.打开python IDE,导入该模块试试:

[root@LGJF-ZYC5-MMSC-WEB02 site-packages]# python
Python 2.7.5 (default, May 3 2017, 07:55:04) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-14)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pychartdir

5.运行脚本,执行成功!

到此这篇关于python模块pychartdir导入问题的文章就介绍到这了,更多相关python模块pychartdir内容请搜索python博客以前的文章或继续浏览下面的相关文章希望大家以后多多支持python博客!

展开全文
上一篇:Python实现自动装机功能案例分析
下一篇:python使用ctypes库调用DLL动态链接库
输入字:
相关知识
Python 实现图片色彩转换案例

我们在看动漫、影视作品中,当人物在回忆过程中,体现出来的画面一般都是黑白或者褐色的。本文将提供将图片色彩转为黑白或者褐色风格的案例详解,感兴趣的小伙伴可以了解一下。

python初学定义函数

这篇文章主要为大家介绍了python的定义函数,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,希望能够给你带来帮助,希望能够给你带来帮助

图文详解Python如何导入自己编写的py文件

有时候自己写了一个py文件,想要把它导入到另一个py文件里面,所以下面这篇文章主要给大家介绍了关于Python如何导入自己编写的py文件的相关资料,需要的朋友可以参考下

python二分法查找实例代码

二分算法是一种效率比较高的查找算法,其输入的是一个有序的元素列表,如果查找元素包含在列表中,二分查找返回其位置,否则返回NONE,下面这篇文章主要给大家介绍了关于python二分法查找的相关资料,需要的朋友可以参考下