詳解python模塊pychartdir安裝及導(dǎo)入問題
在遷移別人寫好的腳本時,發(fā)現(xiàn)pychartdir沒有導(dǎo)入,腳本執(zhí)行報錯。以下是報錯內(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來安裝模塊的,先安裝下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)報錯了,報錯的大概意思為:未找到合適的版本。
那么就只好手動安裝了
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)建一個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,將其下面的內(nèi)容拷貝到上邊創(chuàng)建的目錄下,同時在site-packages下創(chuàng)建一個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.運行腳本,執(zhí)行成功!
到此這篇關(guān)于python模塊pychartdir導(dǎo)入問題的文章就介紹到這了,更多相關(guān)python模塊pychartdir內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Python實現(xiàn)Excel和CSV之間的相互轉(zhuǎn)換
通過使用Python編程語言,編寫腳本來自動化Excel和CSV之間的轉(zhuǎn)換過程,可以批量處理大量文件,定期更新數(shù)據(jù),并集成轉(zhuǎn)換過程到自動化工作流程中,本文將介紹如何使用Python 實現(xiàn)Excel和CSV之間的相互轉(zhuǎn)換,需要的朋友可以參考下2024-03-03
Python2與python3中 for 循環(huán)語句基礎(chǔ)與實例分析
Python for循環(huán)可以遍歷任何序列的項目,如一個列表或者一個字符串,也是python中比較常用的一個函數(shù),這里通過基礎(chǔ)與實例給大家分享一下2017-11-11
Python根據(jù)指定日期計算后n天,前n天是哪一天的方法
這篇文章主要介紹了Python根據(jù)指定日期計算后n天,前n天是哪一天的方法,涉及Python日期與時間計算相關(guān)操作技巧,需要的朋友可以參考下2018-05-05
利用Python-iGraph如何繪制貼吧/微博的好友關(guān)系圖詳解
這篇文章主要給大家介紹了關(guān)于利用Python-iGraph如何繪制貼吧/微博好友關(guān)系圖的相關(guān)資料,文中顯示介紹了在windows系統(tǒng)下安裝python-igraph的步驟,然后通過示例代碼演示了繪制好友關(guān)系圖的方法,需要的朋友可以參考下。2017-11-11
Pytest初學(xué)者快速上手高效Python測試指南
這篇文章主要為大家介紹了Pytest初學(xué)者快速上手的高效Python測試指南,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2024-01-01

