Python2.7安裝ipython報錯解決


一、問題描述

使用pip安裝ipython pip install ipython,出現報錯

Using cached https://mirrors.aliyun.com/pypi/packages/71/bd/042e63027bea950da4e6f5545eb59b973868da854ab30a18128d3b884104/decorator-5.0.2.tar.gz (33 kB)
ERROR: Command errored out with exit status 1:
   command: /root/.pyenv/versions/2.7.17/bin/python2.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-Wp57Mm/decorator/setup.py'"'"';     __file__='"'"'/tmp/pip-install-Wp57Mm/decorator/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-kyIsC3
       cwd: /tmp/pip-install-Wp57Mm/decorator/
  Complete output (8 lines):
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-Wp57Mm/decorator/setup.py", line 4, in <module>
      exec(open('src/decorator.py').read(), dic)  # extract the __version__
    File "<string>", line 162
      print('Error in generated code:', file=sys.stderr)
                                            ^
  SyntaxError: invalid syntax
  ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

二、問題解決

按照網上搜索辦法,pip install --upgrade setuptools && python -m pip install --upgrade pip,升級setuptools和pip,依舊報錯。
嘗試下載ipython的whl包,本地安裝,下載地址https://www.lfd.uci.edu/~gohlke/pythonlibs/,下載完成,執行pip install ipython-5.8.0-py2-none-any.whl,依舊報錯。
然后仔細檢查報錯,發現錯誤發生前在Using cached https://mirrors.aliyun.com/pypi/packages/71/bd/042e63027bea950da4e6f5545eb59b973868da854ab30a18128d3b884104/decorator- 5.0.2.tar.gz (33 kB),於是嘗試手動下載decorator‑4.4.1‑py2.py3‑none‑any.whl包到本地。
然后手動執行,pip install decorator-4.4.1-py2.py3-none-any.whl,再安裝ipython,pip install ipython-5.8.0-py2-none-any.whl,ok,問題解決。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM