我的环境:Windows10 64、Python 3.7、Django 2.2
IDE:Visual Studio Code
我设置了一个虚拟环境并激活了它。
然后我试图用命令安装djangorestframework
pipenv install djangorestframework
错误:
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:1074: The handshake operation timed out'))': /simple/djangorestframework/
ERROR: Could not find a version that satisfies the requirement djangorestframework
ERROR: No matching distribution found for djangorestframework
以下是我在env中安装的内容。
python -m pip list
Package Version
------------------- -------
astroid 2.4.2
colorama 0.4.4
Django 2.2
isort 5.6.4
lazy-object-proxy 1.4.3
mccabe 0.6.1
pip 20.3
pylint 2.6.0
pylint-django 2.3.0
pylint-plugin-utils 0.6
pytz 2020.4
setuptools 50.3.2
six 1.15.0
sqlparse 0.4.1
toml 0.10.2
typed-ast 1.4.1
wheel 0.35.1
wrapt 1.12.1
当我尝试时
pip install djangorestframework
它奏效了。
我在虚拟环境中错过了什么?
请帮我安装这个软件包。
尝试升级您的pip类型
python-m pip安装-升级pip
根据此链接:https://dev.to/habibaudu/simple-rest-api-with-django-rest-framework-4bmc
您可以使用pipenv安装django-rest框架,方法如下:pipenv install djangorestframework
然后,您应该将django-rest框架添加到settings.py文件中的INSTALLED_APPS中。
INSTALLED_APPS = [ 'django.contrib.admin', 'rest_framework', ]
改为使用这个:
pipenv install rest_framework