• 微信公众号:美女很有趣。 工作之余,放松一下,关注即送10G+美女照片!

Python2.7安装ipython报错解决

开发技术 开发技术 2周前 (04-06) 8次浏览

一、问题描述

使用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('"'"'rn'"'"', '"'"'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,问题解决。


程序员灯塔
转载请注明原文链接:Python2.7安装ipython报错解决
喜欢 (0)