V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
ecloud
V2EX  ›  Python

看来是时候向 python2 告别了

  •  
  •   ecloud ·
    yecloud · 2019-12-12 11:53:07 +08:00 · 3678 次点击
    这是一个创建于 1839 天前的主题,其中的信息可能已经有所发展或是发生改变。

    最近要用 astropy 做点东西,2.7 用 pip 装上以后还装了一大堆额外的包,然而还是不好用……

    AstroT4:~ zachary$ python test.py
    'import sitecustomize' failed; use -v for traceback
    Traceback (most recent call last):
      File "test.py", line 4, in <module>
        from astropy import units as u
      File "/usr/local/Cellar/python@2/2.7.17/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy/__init__.py", line 116, in <module>
        _check_numpy()
      File "/usr/local/Cellar/python@2/2.7.17/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy/__init__.py", line 110, in _check_numpy
        raise ImportError(msg)
    ImportError: Numpy version 1.9.0 or later must be installed to use Astropy
    AstroT4:~ zachary$ pip show numpy
    'import sitecustomize' failed; use -v for traceback
    DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
    Name: numpy
    Version: 1.14.1
    Summary: NumPy: array processing for numbers, strings, records, and objects.
    Home-page: http://www.numpy.org
    Author: NumPy Developers
    Author-email: [email protected]
    License: BSD
    Location: /usr/local/lib/python2.7/site-packages
    Requires:
    Required-by: pyfits, matplotlib, astropy
    

    简直不可理喻(我估计现在向任何人提关于 2.7 的 bug 都不会有反馈的)

    然后换 python3,pip 只装了一个 astropy 包,运行起来没有任何问题😃

    1 条回复    2019-12-12 13:14:47 +08:00
    lihongjie0209
        1
    lihongjie0209  
       2019-12-12 13:14:47 +08:00
    对于你这种类型的用户来说是可以升级到 python3

    但是对于运维来说, 系统自带什么版本就用什么版本,CentOS 7 到现在还是 2.7, 只要 CentOS 7 还在线上跑, 我估计 2.7 要会用下去
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3478 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 04:59 · PVG 12:59 · LAX 20:59 · JFK 23:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.