ImportError: No module named prettytable的處理方法
阿新 • • 發佈:2018-03-25
python1、報錯現象:
執行某個python腳本的時候,出現下圖的報錯
2、解決方法
# wget https://pypi.python.org/packages/source/P/PrettyTable/prettytable-0.7.2.tar.gz --2018-03-24 23:04:03-- https://pypi.python.org/packages/source/P/PrettyTable/prettytable-0.7.2.tar.gz 正在解析主機 pypi.python.org (pypi.python.org)... 151.101.228.223, 2a04:4e42:36::223 正在連接 pypi.python.org (pypi.python.org)|151.101.228.223|:443... 已連接。 已發出 HTTP 請求,正在等待回應... 200 OK 長度:24784 (24K) [application/octet-stream] 正在保存至: “prettytable-0.7.2.tar.gz” 100%[===============================================================>] 24,784 --.-K/s 用時 0.1s 2018-03-24 23:04:05 (208 KB/s) - 已保存 “prettytable-0.7.2.tar.gz” [24784/24784]) # tar -xf prettytable-0.7.2.tar.gz # cd prettytable-0.7.2 # python setup.py build running build running build_py creating build creating build/lib copying prettytable.py -> build/lib # python setup.py install running install running bdist_egg running egg_info writing prettytable.egg-info/PKG-INFO writing top-level names to prettytable.egg-info/top_level.txt writing dependency_links to prettytable.egg-info/dependency_links.txt reading manifest file ‘prettytable.egg-info/SOURCES.txt‘ reading manifest template ‘MANIFEST.in‘ writing manifest file ‘prettytable.egg-info/SOURCES.txt‘ installing library code to build/bdist.linux-x86_64/egg running install_lib running build_py creating build/bdist.linux-x86_64 creating build/bdist.linux-x86_64/egg copying build/lib/prettytable.py -> build/bdist.linux-x86_64/egg byte-compiling build/bdist.linux-x86_64/egg/prettytable.py to prettytable.pyc creating build/bdist.linux-x86_64/egg/EGG-INFO copying prettytable.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO copying prettytable.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying prettytable.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying prettytable.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO zip_safe flag not set; analyzing archive contents... creating dist creating ‘dist/prettytable-0.7.2-py2.7.egg‘ and adding ‘build/bdist.linux-x86_64/egg‘ to it removing ‘build/bdist.linux-x86_64/egg‘ (and everything under it) Processing prettytable-0.7.2-py2.7.egg Copying prettytable-0.7.2-py2.7.egg to /usr/lib/python2.7/site-packages Adding prettytable 0.7.2 to easy-install.pth file Installed /usr/lib/python2.7/site-packages/prettytable-0.7.2-py2.7.egg Processing dependencies for prettytable==0.7.2 Finished processing dependencies for prettytable==0.7.2
3、驗證
# python getosdcpu.py t
thread
+-------------+----+----+
| OSD\CPU | 0 | 1 |
+-------------+----+----+
| Core ID | 0 | 0 |
| Physical ID | 0 | 1 |
| ----------- | -- | -- |
+-------------+----+----+
ImportError: No module named prettytable的處理方法