溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

python中的pychartdir模塊如何安裝及導(dǎo)入

發(fā)布時(shí)間:2020-10-26 16:02:29 來(lái)源:億速云 閱讀:503 作者:Leah 欄目:開發(fā)技術(shù)

這期內(nèi)容當(dāng)中小編將會(huì)給大家?guī)?lái)有關(guān)python中的pychartdir模塊如何安裝及導(dǎo)入,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

在遷移別人寫好的腳本時(shí),發(fā)現(xiàn)pychartdir沒有導(dǎo)入,腳本執(zhí)行報(bào)錯(cuò)。以下是報(bào)錯(cuò)內(nèi)容:

[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來(lái)安裝模塊的,先安裝下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

發(fā)現(xiàn)報(bào)錯(cuò)了,報(bào)錯(cuò)的大概意思為:未找到合適的版本。

那么就只好手動(dòng)安裝了

1.從官方地址下載python版本的ChartDirector并解壓

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

# 使用lrzsz命令將下載的包傳遞到服務(wù)器上
[root@LGJF-ZYC5-MMSC-WEB02 ~]# tar -xf chartdir_python_linux_64.tar.gz

2.在python模塊安裝目錄下(/usr/lib/python2.7/site-packages)創(chuàng)建一個(gè)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.進(jìn)入解壓好的Chartdirector/ lib,將其下面的內(nèi)容拷貝到上邊創(chuàng)建的目錄下,同時(shí)在site-packages下創(chuàng)建一個(gè)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,導(dǎo)入該模塊試試:

[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.運(yùn)行腳本,執(zhí)行成功!

上述就是小編為大家分享的python中的pychartdir模塊如何安裝及導(dǎo)入了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI