简体   繁体   English

如何将 python 2.7.16 更换为 python 3?

[英]How to replace python 2.7.16 to python 3?

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)

Due this error unable to install the djengo.由于此错误无法安装 djengo。

pip install django

On the command line, run在命令行上,运行

$ python3

If you see an output like:如果您看到 output 像:

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

then you have both Python 3 and 2 installed in your machine.那么您的机器中同时安装了 Python 3 和 2。 This means that you need to run pip3 install django .这意味着您需要运行pip3 install django

If not, then:如果没有,那么:

  • you can reinstall Python from the official website你可以从官网重新安装Python

  • you can build Python from source您可以从源代码构建 Python

  • you can use this command (from Fareed Alnamrouti's answer in Updating Python on Mac ):您可以使用此命令(来自 Fareed Alnamrouti 在 Mac 上更新 Python 中的回答):

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Vscode 显示 Python 2.7.16 ... 我如何更改为 3.8? - Vscode shown Python 2.7.16... How can I change to 3.8? 如何将旧的python 2.7.x版本升级到2.7.16? - How to upgrade older python 2.7.x version to 2.7.16? 如何克服“Package ‘whitenoise’ requires a different Python: 2.7.16”错误? - How to overcome "Package 'whitenoise' requires a different Python: 2.7.16" error? Python 2.7.16-正则表达式无法在Findall上使用 - Python 2.7.16 - regex lookbehind not working with Findall 如何在 macOS Catalina 版本 10.15.7 上卸载 Python 2.7.16 或如何切换到 Python 3.9.2? - How to uninstall Python 2.7.16 on a macOS Catalina Version 10.15.7 or how to switch to Python 3.9.2? 如何将我的 Visual Studio Code 终端上的 python 版本 2.7.16 更改为更新的 python 版本? - How change the python version 2.7.16 on my Visual Studio Code terminal to the newer python version? Python 3.8.5 安装在 MacOS 上,但 python --version 返回 2.7.16 -- 我该如何解决这个问题? - Python 3.8.5 installed on MacOS but python --version returns 2.7.16 -- How do I fix this? 安装3.8后如何防止终端捡起旧的python版本2.7.16 - How to prevent terminal from picking up old python version 2.7.16 after installing 3.8 终端输出:Python 2.7.16 即使我安装了 3.8.2 - Terminal outputting: Python 2.7.16 Even though I have 3.8.2 installed Python 2.7.16 - 导入错误:没有名为 etree.ElementTree 的模块 - Python 2.7.16 - ImportError: No module named etree.ElementTree
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM