I can’t install packages in venv!!
(36, <My Virtual Env's Name>) user@localhost:~/workspace/django-nginx/36$ pip install django
WARNING: The directory '/home/user/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/home/user/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting django
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/home/user/.cache/pip/wheels/2b/fe/4a/1043507723e1292a145a1456bdebdaf19283baf01f4a7bb33e'
Consider using the `--user` option or check the permissions.(36)user@localhost:~/workspace/django-nginx/36$ pip install django --user
WARNING: The directory '/home/user/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/home/user/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting django
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/home/user/.cache/pip/wheels/2b/fe/4a/1043507723e1292a145a1456bdebdaf19283baf01f4a7bb33e'
Check the permissions.
(36) user@localhost:~/workspace/django-nginx/36$ sudo -H pip install django
Collecting django
Downloading https://files.pythonhosted.org/packages/b1/1d/2476110614367adfb079a9bc718621f9fc8351e9214e1750cae1832d4090/Django-2.2.1-py3-none-any.whl (7.4MB)
|████████████████████████████████| 7.5MB 211kB/s
Requirement already satisfied: pytz in /usr/local/lib/python3.6/dist-packages (from django) (2018.4)
Collecting sqlparse (from django)
Downloading https://files.pythonhosted.org/packages/ef/53/900f7d2a54557c6a37886585a91336520e5539e3ae2423ff1102daf4f3a7/sqlparse-0.3.0-py2.py3-none-any.whl
Installing collected packages: sqlparse, django
Successfully installed django-2.2.1 sqlparse-0.3.0
I can’t not only install packages but also upgrade pip.
(36)user@localhost:~/workspace/django-nginx$ pip install --upgrade pip
The directory '/home/user/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/user/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pip
Downloading https://files.pythonhosted.org/packages/5c/e0/be401c003291b56efc55aeba6a80ab790d3d4cece2778288d65323009420/pip-19.1.1-py2.py3-none-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 330kB/s
Installing collected packages: pip
Found existing installation: pip 8.1.1
Uninstalling pip-8.1.1:
Successfully uninstalled pip-8.1.1
Successfully installed pip-19.1.1
(36)user@localhost:~/workspace/django-nginx$
My solution:
user@localhost:~/workspace/django-nginx$ pip --no-cache-dir <package>
For example:
(36)user@localhost:~/workspace/django-nginx$ pip --no-cache-dir install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/5c/e0/be401c003291b56efc55aeba6a80ab790d3d4cece2778288d65323009420/pip-19.1.1-py2.py3-none-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 1.6MB/s
Installing collected packages: pip
Found existing installation: pip 8.1.1
Uninstalling pip-8.1.1:
Successfully uninstalled pip-8.1.1
Successfully installed pip-19.1.1
(36)user@localhost:~/workspace/django-nginx$ pip --no-cache-dir install django
Collecting django
Downloading https://files.pythonhosted.org/packages/b1/1d/2476110614367adfb079a9bc718621f9fc8351e9214e1750cae1832d4090/Django-2.2.1-py3-none-any.whl (7.4MB)
|████████████████████████████████| 7.5MB 1.0MB/s
Collecting pytz (from django)
Downloading https://files.pythonhosted.org/packages/3d/73/fe30c2daaaa0713420d0382b16fbb761409f532c56bdcc514bf7b6262bb6/pytz-2019.1-py2.py3-none-any.whl (510kB)
|████████████████████████████████| 512kB 1.5MB/s
Collecting sqlparse (from django)
Downloading https://files.pythonhosted.org/packages/ef/53/900f7d2a54557c6a37886585a91336520e5539e3ae2423ff1102daf4f3a7/sqlparse-0.3.0-py2.py3-none-any.whl
Installing collected packages: pytz, sqlparse, django
Successfully installed django-2.2.1 pytz-2019.1 sqlparse-0.3.0
(36)user@localhost:~/workspace/django-nginx$ pip freeze
Django==2.2.1
pkg-resources==0.0.0
pytz==2019.1
sqlparse==0.3.0
(36)user@localhost:~/workspace/django-nginx$
About “ cache”
Starting with v6.0, pip provides an on-by-default cache which functions similarly to that of a web browser. While the cache is on by default and is designed do the right thing by default you can disable the cache and always access PyPI by utilizing the
--no-cache-dir
option.
sources;
Tips:
Q1. What is cached?
A1. Cached: store away in hiding or for future use
Q2. What is the cache used for?
A2. It is used to store the installation files(.whl, etc) of the modules that you install through pip.
Q3. Why would I want to disable it?
A3. If you don’t have space on your hard drive you might want to disable it
sources;
P.S. It seems that the function of pip has changed in the first place
pip provides a number of facilities for speeding up installation by using local cached copies of packages:
sources;