SoFunction
Updated on 2024-12-19

Detailed python module pychartdir installation and import issues

While migrating a script written by someone else, it was discovered that thepychartdirThere is no import and the script execution reports an error. The following is the content of the error:

[modps@LGJF-ZYC5-MMSC-WEB02 ~]$ python /opt/aspire/product/modps/mopps/shell/dayreport_linux.py
/etc/: 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

Previously usedpipto install the module, install pip first:

curl / -o 
sudo python 

Then start downloading the pychartdir module:

[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 /en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
/etc/: 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

Found out that an error was reported, which roughly translates to: no suitable version found.

Then we'll have to install it manually

1. Download the python version of ChartDirector from the official address and unzip it.

/

# Use the lrzsz command to pass the downloaded package to the server
[root@LGJF-ZYC5-MMSC-WEB02 ~]# tar -xf chartdir_python_linux_64.

2. Create a chartdirector directory in the python module installation directory (/usr/lib/python2.7/site-packages).

# View the module installation directory
[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()
['', '/usr/lib64/', '/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. Go to the unzipped Chartdirector/ lib and copy the contents under it to the directory created above, and also add a new directory in thesite-packagesCreate a, write chartdirector to file:

[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

4. Open the python IDE and try importing the module:

[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. Run the script and it executes successfully!

to this article on the python module pychartdir import problem is introduced to this article, more related python module pychartdir content please search my previous posts or continue to browse the following related articles I hope you will support me in the future more!