1. 程式人生 > 其它 >安裝python第三方庫fire報錯

安裝python第三方庫fire報錯

1. linux環境

報錯

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting fire
  Downloading https://mirrors.aliyun.com/pypi/packages/11/07/a119a1aa04d37bc819940d95ed7e135a7dcca1c098123a3764a6dcace9e7/fire-0.4.0.tar.gz (87 kB)
     |????????????????????????????????| 87 kB 3.8 MB/s 
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-6x44h_/fire/setup.py'"'"'; __file__='"'"'/tmp/pip-install-6x44h_/fire/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-szF2KD
         cwd: /tmp/pip-install-6x44h_/fire/
    Complete output (1 lines):
    error in fire setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

解決方案

該問題主要是因為setuptools工具版本太低,所以只需要升級該軟體即可。升級setuptools版本後安裝fire即可

]# pip install setuptools -U
]# pip install fire

2. windows環境

報錯

(env) Lenovo@Lenovo python> pip install fire
Traceback (most recent call last):
  File "D:\Python27\Lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "D:\Python27\Lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "F:\workspace\cli\python\env\Scripts\pip.exe\__main__.py", line 4, in <module>
  File "f:\workspace\cli\python\env\lib\site-packages\pip\_internal\cli\main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "f:\workspace\cli\python\env\lib\site-packages\pip\_internal\cli\autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "f:\workspace\cli\python\env\lib\site-packages\pip\_internal\cli\main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "f:\workspace\cli\python\env\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 25, in <module>
    from pip._internal.cli.progress_bars import BAR_TYPES
    _BaseBar = _select_progress_class(IncrementalBar, Bar)  # type: Any
  File "f:\workspace\cli\python\env\lib\site-packages\pip\_internal\cli\progress_bars.py", line 48, in _select_progress_class
    six.text_type().join(characters).encode(encoding)
LookupError: unknown encoding: cp65001

解決方案

該問題主要是命令列下字元編碼導致的有些字元無法正常使用,只需修改預設的字元編碼即可。如果繼續報錯,可以修改為其他字元編碼

(env) Lenovo@Lenovo python> chcp 1252 //修改為1252 拉丁1字元 (ANSI)
(env) Lenovo@Lenovo python> pip install fire

參考文件

  1. https://docs.microsoft.com/zh-cn/windows-server/administration/windows-commands/chcp
  2. https://www.cnblogs.com/yuanhy/p/13779600.html