Ubuntu 18.04虚拟环境中pip安装Django报错求助
Hey there, let's figure out how to fix that Django install error you're hitting in your Ubuntu 18.04 virtual environment. The traceback pointing to urllib3 tells us this is probably related to network issues, outdated tools, or problems connecting to the default PyPI repository. Here are some practical steps to try:
Make sure your virtual environment is active
First things first—check if you see(env)at the start of your terminal prompt. If not, activate it with:source /home/sagar/Documents/glug_aud/env/bin/activateUpgrade pip and urllib3 first
Old versions of these tools often cause connection glitches. Run these commands inside your activated venv:pip install --upgrade pip urllib3Try using a PyPI mirror for the install
Sometimes the default PyPI server is slow or unreachable. Use a reliable mirror to install Django:pip install Django -i https://pypi.tuna.tsinghua.edu.cn/simpleCheck your network connection
Verify your system can reach PyPI's servers with a quick test:curl https://pypi.org/simple/django/If this fails, you might need to adjust your firewall settings or switch to a different network.
Recreate your virtual environment if needed
A corrupted venv can cause odd errors. If nothing else works, delete the existing one and start fresh:deactivate rm -rf /home/sagar/Documents/glug_aud/env python3 -m venv /home/sagar/Documents/glug_aud/env source /home/sagar/Documents/glug_aud/env/bin/activate pip install Django
Just to call out the error snippet you shared for context:
Exception: Traceback (most recent call last): File "/home/sagar/Documents/glug_aud/env/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/response.py", line 302, in _error_catcher yield
This error happens when urllib3 can't properly handle the response from the PyPI server, which is almost always tied to the issues we're addressing above. Give these steps a shot—they should get you up and running with Django.
内容的提问来源于stack exchange,提问作者Sagar Agarwal

