看来是时候向 python2 告别了

2019-12-12 11:53:07 +08:00
 ecloud

最近要用 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: numpy-discussion@python.org
License: BSD
Location: /usr/local/lib/python2.7/site-packages
Requires:
Required-by: pyfits, matplotlib, astropy

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

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

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

但是对于运维来说, 系统自带什么版本就用什么版本,CentOS 7 到现在还是 2.7, 只要 CentOS 7 还在线上跑, 我估计 2.7 要会用下去

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/628310

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX