Python3.6.5+pip9.0.3安装Django2.0.5失败,求排查原因
Hey there! Let's break down what's causing your installation issue and how to fix it.
Why You're Seeing This Error
The core problems here are two-fold:
- Outdated pip version & deprecated PyPI source: Your pip 9.0.3 is pretty old, and it defaults to using
pypi.python.org—a source that's no longer maintained. Modern PyPI usespypi.org, and older pip versions can struggle to connect to this new address, especially with network latency or regional restrictions, leading to thoseConnectTimeoutErrormessages. - Failed package lookup: Because pip can't successfully reach the PyPI server, it never gets the list of available Django versions, hence the "No matching distribution found" error (this isn't actually because Django 2.0.5 doesn't exist—it's because pip couldn't fetch the version data).
Good news though: Python 3.6.5 is fully compatible with Django 2.0.5 (Django 2.0.x supports Python 3.5-3.7), so that's not the issue here.
Step-by-Step Fixes
Let's get this sorted out:
Upgrade pip first (using a faster mirror)
Old pip is the root of most of these problems. Run this command to upgrade pip to the latest version using a reliable mirror (avoids timeout issues):python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simpleInstall Django 2.0.5 with the same mirror
Once pip is updated, install Django using the mirror to ensure a smooth download:pip install Django==2.0.5 -i https://pypi.tuna.tsinghua.edu.cn/simpleVerify the installation
After running the commands, check if Django is installed correctly with:django-admin --versionYou should see
2.0.5printed out if everything worked.
Quick Note
If you run into any permission issues (common on macOS/Linux), add --user to the end of the pip commands to install the packages for your user account only, instead of system-wide.
内容的提问来源于stack exchange,提问作者Jayalakshmi

