安装openpyxl时出现属性错误

时间:2018-01-11 23:06:03

标签: python pip openpyxl

我最近刚刚开始使用Python,并希望如何解决这个问题。我如何绕过这个并成功安装 openpyxl 模块?

>> pip.main(['install', 'openpyxl==2.4.7'])
Collecting openpyxl==2.4.7
Downloading openpyxl-2.4.7.tar.gz (156kB)

[K    6% |##                              | 10kB 10.3MB/s eta 0:00:01
[K    13% |####                            | 20kB 1.1MB/s eta 0:00:01
[K    19% |######                          | 30kB 767kB/s eta 0:00:01
[K    26% |########                        | 40kB 580kB/s eta 0:00:01
[K    32% |##########                      | 51kB 539kB/s eta 0:00:01
[K    39% |############                    | 61kB 532kB/s eta 0:00:01
[K    45% |##############                  | 71kB 535kB/s eta 0:00:01
[K    52% |################                | 81kB 532kB/s eta 0:00:01
[K    58% |##################              | 92kB 529kB/s eta 0:00:01
[K    65% |####################            | 102kB 535kB/s eta 0:00:01
[K    71% |#######################         | 112kB 487kB/s eta 0:00:01
[K    78% |#########################       | 122kB 478kB/s eta 0:00:01
[K    85% |###########################     | 133kB 473kB/s eta 0:00:01
[K    91% |#############################   | 143kB 484kB/s eta 0:00:01
[K    98% |############################### | 153kB 483kB/s eta 0:00:01
[K    100% |################################| 163kB 402kB/s 
[31mException:
Traceback (most recent call last):
  File "C:\Program Files\Python36\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
  File "C:\Program Files\Python36\lib\site-packages\pip\commands\install.py", line 324, in run
requirement_set.prepare_files(finder)
  File "C:\Program Files\Python36\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
  File "C:\Program Files\Python36\lib\site-packages\pip\req\req_set.py", line 634, in _prepare_file
abstract_dist.prep_for_dist()
   File "C:\Program Files\Python36\lib\site-packages\pip\req\req_set.py", line 129, in prep_for_dist
self.req_to_install.run_egg_info()
  File "C:\Program Files\Python36\lib\site-packages\pip\req\req_install.py", line 439, in run_egg_info
command_desc='python setup.py egg_info')
  File "C:\Program Files\Python36\lib\site-packages\pip\utils\__init__.py", line 676, in call_subprocess
line = console_to_str(proc.stdout.readline())
  File "C:\Program Files\Python36\lib\site-packages\pip\compat\__init__.py", line 73, in console_to_str
return s.decode(sys.__stdout__.encoding)
AttributeError: 'NoneType' object has no attribute 'encoding'[0m

1 个答案:

答案 0 :(得分:1)

首先,尝试从命令行运行pip;不是来自Python提示符。

pip install openpyxl == 2.4.7

其次,如果您使用的是Windows系统,请确保从cmd提示符“以管理员身份运行”中运行pip命令。