where are cached python packages stored in Ubuntu?

7,068

Thanks to @muru, I found the answer in Stackoverflow. I quote from it:

The default location for the cache directory depends on the Operating System:

For Ubuntu, it is located in:

~/.cache/pip and it respects the XDG_CACHE_HOME directory.

WheelCache
Pip will read from the subdirectory wheels within the pip cache directory and use any packages found there.

More information can be found in this link

Share:
7,068
singrium
Author by

singrium

A recently graduated Telecommunications engineer. A Python and Linux lover

Updated on September 18, 2022

Comments

  • singrium
    singrium over 1 year

    I thought to post this question in Stackoverflow, but I decided to post it here because it probably depends on the OS.
    When I install a python package using pip, at the first time it is downloaded from pypi:

    pip install numpy
    Collecting numpy
      Downloading https://files.pythonhosted.org/packages/de/37/fe7db552f4507f379d81dcb78e58e05030a8941757b1f664517d581b5553/numpy-1.15.4-cp27-cp27mu-manylinux1_x86_64.whl (13.8MB)
        100% |████████████████████████████████| 13.8MB 792kB/s 
    Installing collected packages: numpy
    Successfully installed numpy-1.15.4
    

    When I uninstall it and reinstall it again, the package is not downloaded. Instead, a cached version is used to install it:

    pip install numpy
    Collecting numpy
      Using cached https://files.pythonhosted.org/packages/de/37/fe7db552f4507f379d81dcb78e58e05030a8941757b1f664517d581b5553/numpy-1.15.4-cp27-cp27mu-manylinux1_x86_64.whl
    Installing collected packages: numpy
    Successfully installed numpy-1.15.4
    

    Sometimes, the installation get corrupted, or problems occur during the installation. So I need to reinstall the same package again. but since there is a cached version, the re-installation will use the same corrupted version. So I need to delete that cached version in order to do a clean installation.
    for that reason, my question is: where are cached python packages stored in Ubuntu?

    • muru
      muru over 5 years
    • abu-ahmed al-khatiri
      abu-ahmed al-khatiri over 5 years
      when you're installed a package python with pip using python2.7, you can check it on /usr/local/lib/python2.7/dist-packages/* path
    • singrium
      singrium over 5 years
      @muru thank you. I will delete my question then. Or shall I just close it?
    • Zanna
      Zanna over 5 years
      I suggest you just write the answer yourself here. If you want to quote something from another post, just use appropriate attribution and go ahead. It is on topic here - just an overlap area :)