Django使用异常汇总
程序员文章站
2022-09-14 20:46:51
使用版本知悉 工作需求是1.11.13(安装时,pip版本较低,2.0以下版本安装会超时,2.0以上版本安装正常) 目录 mac环境下,安装Django 2.0以下版本报错 使用pycharm安装异常截图 使用命令行安装,异常如下 提示安装超时,并建议更新pip版本号 Last login: Thu ......
使用版本知悉
limengjiedeMacBook-Pro:~ limengjie$ python --version Python 3.6.4 :: Anaconda, Inc. limengjiedeMacBook-Pro:~ limengjie$ python -m django --version 1.11.13
工作需求是1.11.13(安装时,pip版本较低,2.0以下版本安装会超时,2.0以上版本安装正常)
目录
mac环境下,安装Django 2.0以下版本报错
使用pycharm安装异常截图
使用命令行安装,异常如下
提示安装超时,并建议更新pip版本号
Last login: Thu Jun 14 16:59:22 on ttys000 limengjiedeMacBook-Pro:~ limengjie$ pip install Django==1.11.13 Collecting Django==1.11.13 Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x10ae0ebe0>, 'Connection to files.pythonhosted.org timed out. (connect timeout=15)')': /packages/25/4d/c8228419346a0e84aec202a43e181afc6572b861d38f8a0306dbce6abef0/Django-1.11.13-py2.py3-none-any.whl Downloading https://files.pythonhosted.org/packages/25/4d/c8228419346a0e84aec202a43e181afc6572b861d38f8a0306dbce6abef0/Django-1.11.13-py2.py3-none-any.whl (6.9MB) 14% |████▊ | 1.0MB 8.9kB/s eta 0:11:03Exception: Traceback (most recent call last): File "/anaconda3/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 232, in _error_catcher yield File "/anaconda3/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 314, in read data = self._fp.read(amt) File "/anaconda3/lib/python3.6/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 60, in read data = self.__fp.read(amt) File "/anaconda3/lib/python3.6/http/client.py", line 449, in read n = self.readinto(b) File "/anaconda3/lib/python3.6/http/client.py", line 493, in readinto n = self.fp.readinto(b) File "/anaconda3/lib/python3.6/socket.py", line 586, in readinto return self._sock.recv_into(b) File "/anaconda3/lib/python3.6/ssl.py", line 1009, in recv_into return self.read(nbytes, buffer) File "/anaconda3/lib/python3.6/ssl.py", line 871, in read return self._sslobj.read(len, buffer) File "/anaconda3/lib/python3.6/ssl.py", line 631, in read v = self._sslobj.read(len, buffer) socket.timeout: The read operation timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/anaconda3/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/anaconda3/lib/python3.6/site-packages/pip/commands/install.py", line 335, in run wb.build(autobuilding=True) File "/anaconda3/lib/python3.6/site-packages/pip/wheel.py", line 749, in build self.requirement_set.prepare_files(self.finder) File "/anaconda3/lib/python3.6/site-packages/pip/req/req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "/anaconda3/lib/python3.6/site-packages/pip/req/req_set.py", line 620, in _prepare_file session=self.session, hashes=hashes) File "/anaconda3/lib/python3.6/site-packages/pip/download.py", line 821, in unpack_url hashes=hashes File "/anaconda3/lib/python3.6/site-packages/pip/download.py", line 659, in unpack_http_url hashes) File "/anaconda3/lib/python3.6/site-packages/pip/download.py", line 882, in _download_http_url _download_url(resp, link, content_file, hashes) File "/anaconda3/lib/python3.6/site-packages/pip/download.py", line 603, in _download_url hashes.check_against_chunks(downloaded_chunks) File "/anaconda3/lib/python3.6/site-packages/pip/utils/hashes.py", line 46, in check_against_chunks for chunk in chunks: File "/anaconda3/lib/python3.6/site-packages/pip/download.py", line 571, in written_chunks for chunk in chunks: File "/anaconda3/lib/python3.6/site-packages/pip/utils/ui.py", line 139, in iter for x in it: File "/anaconda3/lib/python3.6/site-packages/pip/download.py", line 560, in resp_read decode_content=False): File "/anaconda3/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 357, in stream data = self.read(amt=amt, decode_content=decode_content) File "/anaconda3/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 324, in read flush_decoder = True File "/anaconda3/lib/python3.6/contextlib.py", line 99, in __exit__ self.gen.throw(type, value, traceback) File "/anaconda3/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 237, in _error_catcher raise ReadTimeoutError(self._pool, None, 'Read timed out.') pip._vendor.requests.packages.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. You are using pip version 9.0.1, however version 10.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.
解决方案:
You are using pip version 9.0.1, however version 10.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.
按照提示,更新pip版本后,安装正常
limengjiedeMacBook-Pro:~ limengjie$ pip install --upgrade pip Collecting pip Downloading https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl (1.3MB) 100% |████████████████████████████████| 1.3MB 23kB/s Installing collected packages: pip Found existing installation: pip 9.0.1 Uninstalling pip-9.0.1: Successfully uninstalled pip-9.0.1 Successfully installed pip-10.0.1 limengjiedeMacBook-Pro:~ limengjie$ pip install Django==1.11.13 Collecting Django==1.11.13 Downloading https://files.pythonhosted.org/packages/25/4d/c8228419346a0e84aec202a43e181afc6572b861d38f8a0306dbce6abef0/Django-1.11.13-py2.py3-none-any.whl (6.9MB) 100% |████████████████████████████████| 7.0MB 30kB/s Requirement already satisfied: pytz in /anaconda3/lib/python3.6/site-packages (from Django==1.11.13) (2017.3) Installing collected packages: Django Found existing installation: Django 2.0.6 Uninstalling Django-2.0.6: Successfully uninstalled Django-2.0.6 Successfully installed Django-1.11.13
安装成功验证:
方法一:
>>> import django >>> print django.VERSION # Python2的格式 >>> print(django.VERSION) # python3版本 (1, 11, 13, 'final', 0)
方法二:(也是通过查看版本号,python -m django --version)
limengjiedeMacBook-Pro:~ limengjie$ python -m django --version 1.11.13
(续)