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
在命令行上运行
$ python3
如果看到类似这样的输出:
Python 3.8.0 (default, Apr 4 2020, 13:56:23)
然后,您的计算机中同时安装了Python 3和2。这意味着您需要运行pip3 install django
。
如果不是,则:
您可以从官方网站重新安装Python
您可以从源代码构建Python
您可以使用此命令(来自Updating Python on Mac中的Fareed Alnamrouti的回答:
] >>$ brew install python3 && cp /usr/local/bin/python3 /usr/local/bin/python