在python脚本上导入某个包时出错

时间:2015-09-02 02:06:42

标签: python python-2.6

这是我的错误:

Traceback (most recent call last):
  File "./convert.py", line 6, in <module>
    import openpyxl # from https://pythonhosted.org/openpyxl/ or PyPI (e.g. via pip)
ImportError: No module named openpyxl

我已经安装了python包openpyxl但是仍然出现此错误

我正在使用linux python版本2.6.6 任何帮助,请

当我运行python2.7 script.py时,我遇到了这个新错误:

Traceback (most recent call last):
  File "/usr/local/bin/pip", line 7, in <module>
    from pip import main
  File "/usr/local/lib/python2.7/site-packages/pip/__init__.py", line 13, in <module>
    from pip.utils import get_installed_distributions, get_prog
  File "/usr/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 15, in <module>
    import zipfile
  File "/usr/local/lib/python2.7/zipfile.py", line 6, in <module>
    import io
  File "/usr/local/lib/python2.7/io.py", line 51, in <module>
    import _io
ImportError: /usr/local/lib/python2.7/lib-dynload/_io.so: undefined symbol: _PyErr_ReplaceException

1 个答案:

答案 0 :(得分:2)

openpyxl模块有2个依赖模块:1。jdcal 2. et_xmlfile

我能够安装openpyxl模块,这就是我所做的:

1.从https://pypi.python.org/pypi下载openpyxl,jdcal和et_xmlfile并保存jdcal-1.0.tar.gz,et_xmlfile-1.0.0.tar.gz,openpyxl-2.3.0-b2.tar.gz in我系统中的本地文件夹。

2.然后按以下顺序运行命令:

pip install jdcal-1.0.tar.gz
pip install et_xmlfile-1.0.0.tar.gz
pip install openpyxl-2.3.0-b2.tar.gz

openpyxl在此之后成功了。请检查这是否有帮助。