Installing openpyxl with python2.7 results in "ImportError : no module named util"
Installing openpyxl with python2.7 results in "ImportError : no module named util"
我有 Python 2.7.14。我知道 Python 2 已被弃用,但目前我别无选择。
我尝试安装 openpyxl
库。
我下载并解压了 .tar.gz。下载的版本是3.0.3.
当我 运行 python setup.py install
时,我遇到了以下错误:
Traceback (most recent call last):
File "setup.py", line 28, in <module>
from importlib.util import module_from_spec, spec_from_file_location
ImportError: No module named util
如何解决 Python 2.7.14 的这个问题?
来自 openpyxl release history,与 Python2.7 兼容的最新版本是 2.6.4:
https://openpyxl.readthedocs.io/en/stable/changes.html#id16
2.6.4 (2019-09-25)
Final release for Python 2.7 ––––––––––––––––––––––––––––
启动openpyxl 3.0.0,仅Python-3。
因此,您需要安装特定的旧版本。
使用pip
:
$ python -V
Python 2.7.17
$ python -m pip install openpyxl==2.6.4
使用可下载的 tar.gz from PyPi:
$ wget https://files.pythonhosted.org/packages/d6/26/eb28e975b7a37aad38d7ec4f7a0f652bdee6ecf36e6bd06f473c5af9b87b/openpyxl-2.6.4.tar.gz
$ mkdir openpyxl-2.6.4
$ tar -xvzf openpyxl-2.6.4.tar.gz -C openpyxl-2.6.4
$ cd openpyxl-2.6.4
$ python setup.py install
我有 Python 2.7.14。我知道 Python 2 已被弃用,但目前我别无选择。
我尝试安装 openpyxl
库。
我下载并解压了 .tar.gz。下载的版本是3.0.3.
当我 运行 python setup.py install
时,我遇到了以下错误:
Traceback (most recent call last):
File "setup.py", line 28, in <module>
from importlib.util import module_from_spec, spec_from_file_location
ImportError: No module named util
如何解决 Python 2.7.14 的这个问题?
来自 openpyxl release history,与 Python2.7 兼容的最新版本是 2.6.4:
https://openpyxl.readthedocs.io/en/stable/changes.html#id16
2.6.4 (2019-09-25)
Final release for Python 2.7 ––––––––––––––––––––––––––––
启动openpyxl 3.0.0,仅Python-3。
因此,您需要安装特定的旧版本。
使用pip
:
$ python -V
Python 2.7.17
$ python -m pip install openpyxl==2.6.4
使用可下载的 tar.gz from PyPi:
$ wget https://files.pythonhosted.org/packages/d6/26/eb28e975b7a37aad38d7ec4f7a0f652bdee6ecf36e6bd06f473c5af9b87b/openpyxl-2.6.4.tar.gz
$ mkdir openpyxl-2.6.4
$ tar -xvzf openpyxl-2.6.4.tar.gz -C openpyxl-2.6.4
$ cd openpyxl-2.6.4
$ python setup.py install