windows下安装django
环境:
OS:win11
python:3.8
linux下安装也适用
C:\Users\huangxueliang>pip3 install django
Collecting django
Downloading Django-4.2.13-py3-none-any.whl.metadata (4.1 kB)
Collecting asgiref<4,>=3.6.0 (from django)
Downloading asgiref-3.8.1-py3-none-any.whl.metadata (9.3 kB)
Collecting sqlparse>=0.3.1 (from django)
Downloading sqlparse-0.5.0-py3-none-any.whl.metadata (3.9 kB)
Collecting backports.zoneinfo (from django)
Downloading backports.zoneinfo-0.2.1-cp38-cp38-win_amd64.whl.metadata (4.7 kB)
Collecting tzdata (from django)
Downloading tzdata-2024.1-py2.py3-none-any.whl.metadata (1.4 kB)
Collecting typing-extensions>=4 (from asgiref<4,>=3.6.0->django)
Downloading typing_extensions-4.12.2-py3-none-any.whl.metadata (3.0 kB)
Downloading Django-4.2.13-py3-none-any.whl (8.0 MB)
━━━?━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.7/8.0 MB 12.4 kB/s eta 0:09:48
ERROR: Exception:
Traceback (most recent call last):
File "d:\python3.8\lib\site-packages\pip\_vendor\urllib3\response.py", line 438, in _error_catcher
yield
File "d:\python3.8\lib\site-packages\pip\_vendor\urllib3\response.py", line 561, in read
data = self._fp_read(amt) if not fp_closed else b""
File "d:\python3.8\lib\site-packages\pip\_vendor\urllib3\response.py", line 527, in _fp_read
return self._fp.read(amt) if amt is not None else self._fp.read()
File "d:\python3.8\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 98, in read
data: bytes = self.__fp.read(amt)
File "d:\python3.8\lib\http\client.py", line 455, in read
n = self.readinto(b)
File "d:\python3.8\lib\http\client.py", line 499, in readinto
n = self.fp.readinto(b)
File "d:\python3.8\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "d:\python3.8\lib\ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "d:\python3.8\lib\ssl.py", line 1099, in read
return 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 "d:\python3.8\lib\site-packages\pip\_internal\cli\base_command.py", line 180, in exc_logging_wrapper
status = run_func(*args)
File "d:\python3.8\lib\site-packages\pip\_internal\cli\req_command.py", line 245, in wrapper
return func(self, options, args)
File "d:\python3.8\lib\site-packages\pip\_internal\commands\install.py", line 377, in run
requirement_set = resolver.resolve(
File "d:\python3.8\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 179, in resolve
self.factory.preparer.prepare_linked_requirements_more(reqs)
File "d:\python3.8\lib\site-packages\pip\_internal\operations\prepare.py", line 552, in prepare_linked_requirements_more
self._complete_partial_requirements(
File "d:\python3.8\lib\site-packages\pip\_internal\operations\prepare.py", line 467, in _complete_partial_requirements
for link, (filepath, _) in batch_download:
File "d:\python3.8\lib\site-packages\pip\_internal\network\download.py", line 183, in __call__
for chunk in chunks:
File "d:\python3.8\lib\site-packages\pip\_internal\cli\progress_bars.py", line 53, in _rich_progress_bar
for chunk in iterable:
File "d:\python3.8\lib\site-packages\pip\_internal\network\utils.py", line 63, in response_chunks
for chunk in response.raw.stream(
File "d:\python3.8\lib\site-packages\pip\_vendor\urllib3\response.py", line 622, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "d:\python3.8\lib\site-packages\pip\_vendor\urllib3\response.py", line 587, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "d:\python3.8\lib\contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
File "d:\python3.8\lib\site-packages\pip\_vendor\urllib3\response.py", line 443, in _error_catcher
raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
解决办法:
pip3 --default-timeout=1000 install -U django
C:\Users\huangxueliang>pip3 --default-timeout=1000 install -U django
Collecting django
Using cached Django-4.2.13-py3-none-any.whl.metadata (4.1 kB)
Collecting asgiref<4,>=3.6.0 (from django)
Using cached asgiref-3.8.1-py3-none-any.whl.metadata (9.3 kB)
Collecting sqlparse>=0.3.1 (from django)
Using cached sqlparse-0.5.0-py3-none-any.whl.metadata (3.9 kB)
Collecting backports.zoneinfo (from django)
Using cached backports.zoneinfo-0.2.1-cp38-cp38-win_amd64.whl.metadata (4.7 kB)
Collecting tzdata (from django)
Using cached tzdata-2024.1-py2.py3-none-any.whl.metadata (1.4 kB)
Collecting typing-extensions>=4 (from asgiref<4,>=3.6.0->django)
Using cached typing_extensions-4.12.2-py3-none-any.whl.metadata (3.0 kB)
Downloading Django-4.2.13-py3-none-any.whl (8.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.0/8.0 MB 15.3 kB/s eta 0:00:00
Downloading asgiref-3.8.1-py3-none-any.whl (23 kB)
Downloading sqlparse-0.5.0-py3-none-any.whl (43 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 44.0/44.0 kB 19.8 kB/s eta 0:00:00
Downloading backports.zoneinfo-0.2.1-cp38-cp38-win_amd64.whl (38 kB)
Downloading tzdata-2024.1-py2.py3-none-any.whl (345 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 345.4/345.4 kB 11.8 kB/s eta 0:00:00
Downloading typing_extensions-4.12.2-py3-none-any.whl (37 kB)
Installing collected packages: tzdata, typing-extensions, sqlparse, backports.zoneinfo, asgiref, django
Successfully installed asgiref-3.8.1 backports.zoneinfo-0.2.1 django-4.2.13 sqlparse-0.5.0 typing-extensions-4.12.2 tzdata-2024.1