Django 2.1.5安装遇pytz依赖超时,本地安装后仍报错求助
It looks like the issue here is that your manually installed pytz isn't accessible in the Django virtual environment you created, and pip is still trying to fetch dependencies from PyPI even when you re-run the install steps. Let's break down how to fix this:
Step 1: Install pytz in the correct virtual environment
The pytz you installed earlier was added to your system-level Python, not the isolated virtual environment for Django. Here's how to install it in the right place:
- Activate your Django virtual environment first:
source /u01/django/bin/activate - Now use the virtual environment's pip to install your local pytz package:
(Once the virtual env is activated,pip install /u01/pytz-2018.9pippoints to/u01/django/bin/pip3, so you don't need to specify the full path.)
Step 2: Install Django without fetching remote dependencies
When using pip install -e (editable mode), pip will still attempt to resolve and download dependencies from PyPI by default—even if you've already installed them locally. To skip this and use the pytz you just installed in the virtual env:
- Make sure your virtual environment is still active, then run:
Thepip install -e /u01/Django-2.1.5 --no-deps--no-depsflag tells pip not to check for or download any required dependencies, since you've already handled pytz manually.
Step 3: Verify the installation
To confirm everything worked, run this command (with the virtual env active):
python -m django --version
You should see 2.1.5 printed if the installation was successful.
Why your previous attempt failed
- You installed pytz using your system's
pip3(from/u01/Python-3.7.2/bin), which doesn't affect the isolated virtual environment at/u01/django. Virtual environments don't inherit packages from the system Python unless explicitly configured to do so. - Even if you had installed pytz in the virtual env, the default
pip install -ecommand would still try to reach PyPI to validate dependency versions, which was failing due to your connection timeout. The--no-depsflag bypasses this check.
内容的提问来源于stack exchange,提问作者techie11

