【发布时间】:2014-11-16 09:02:54
【问题描述】:
我已经在我的系统中安装了 python2.6.6 的 argpath 包。但是当我尝试运行需要 argparser 模块的脚本时,仍然抛出错误“ImportError: No module named argparse”
我使用的是 Fedora 20,所以默认版本是 Python 2.7。所以我在其他路径(别名 python='/usr/local/bin/python2.6')中安装了 python 2.6,并且我使用 pip 工具安装了 argparser,如下所示,它说“安装成功”
[root@127 python2.6]# pip install --target=/usr/bin/Python2.6/lib/python2.6/ argparse
Downloading/unpacking argparse
Downloading argparse-1.2.1.tar.gz (69kB): 69kB downloaded
Running setup.py egg_info for package argparse
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '*.pyo' found anywhere in distribution
warning: no previously-included files matching '*.orig' found anywhere in distribution
warning: no previously-included files matching '*.rej' found anywhere in distribution
no previously-included directories found matching 'doc/_build'
no previously-included directories found matching 'env24'
no previously-included directories found matching 'env25'
no previously-included directories found matching 'env26'
no previously-included directories found matching 'env27'
Installing collected packages: argparse
Running setup.py install for argparse
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '*.pyo' found anywhere in distribution
warning: no previously-included files matching '*.orig' found anywhere in distribution
warning: no previously-included files matching '*.rej' found anywhere in distribution
no previously-included directories found matching 'doc/_build'
no previously-included directories found matching 'env24'
no previously-included directories found matching 'env25'
no previously-included directories found matching 'env26'
no previously-included directories found matching 'env27'
Successfully installed
argparse
Cleaning up...
但是当我尝试运行我的 python 脚本时,它仍然说与下面相同的错误
[root@127 python2.6]# python /home/rajamm/python_scripts/json2csv.py -f /home/rajamm/python_scripts/cvl.json -o /home/rajamm/python_scripts/cvl.csv
Exception in user code:
------------------------------------------------------------
Traceback (most recent call last):
File "/home/rajamm/python_scripts/json2csv.py", line 6, in <module>
import fileinput, argparse, json, csv
ImportError: No module named argparse
------------------------------------------------------------
Exiting1.
我在这个问题上坚持了 2 天。请就此向我提出建议。
【问题讨论】:
标签: python python-2.7 pip fedora python-2.6