【问题标题】:How to replace python 2.7.16 to python 3?如何将 python 2.7.16 替换为 python 3?
【发布时间】:2020-07-18 02:00:00
【问题描述】:
MacBook-Pro:~ bsr$ pip install django

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. 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
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: django in ./Library/Python/2.7/lib/python/site-packages (1.11.29)
Requirement already satisfied: pytz in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from django) (2013.7)

由于这个错误无法安装 djengo。

pip install django

【问题讨论】:

标签: python django python-2.7 pip python-3.7


【解决方案1】:

在命令行上运行

$ python3

如果您看到如下输出:

Python 3.8.0 (default, Apr 4 2020, 13:56:23) 

那么你的机器上同时安装了 Python 3 和 2。这意味着您需要运行pip3 install django

如果没有,那么:

  • 可以从官网重新安装Python

  • 您可以从源代码构建 Python

  • 您可以使用此命令(来自 Fareed Alnamrouti 在Updating Python on Mac 中的回答):

$ brew install python3 && cp /usr/local/bin/python3 /usr/local/bin/python

【讨论】:

  • 非常感谢您解决了我的问题,它对我有用。
猜你喜欢
  • 2021-05-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-08
  • 2016-05-01
  • 2014-08-08
  • 1970-01-01
相关资源
最近更新 更多