How to install PIP packages Offline?
Are you trying to install a package offline? Or Is the package size large & PIP install keeps failing from Pypi.org?
Well, if that is the case then first downloading the package to your PC would be better than directly installing it via pip install <package name>.
So, let’s take a look at the process step by step. I’ve also included a video at the end of this article for better clarity.
Let’s get started:
- First, open pypi.org or anywhere really, where the package file is.
- We are looking for either .whl (wheel extension) or .tar.gz. The earlier one will get installed pretty quickly because .wheel format is natively supported by Python programming language.
- With .tar.gz the file will be processed & then converted to .whl format & then installed in your system.
- For our example, we’ll take a look at pypi.org download process.
- Search for your library.
Select it from the list of packages.
Click on Download files
You’ll be able to see all the download files related to that library.
- Download any one of the files…let’s take .whl one for example.
- Once it is downloaded…locate it in your File Explorer.
- By default, it will be in your downloads folder.
Hold shift-key & right-click the file…we are looking for copy as path option.
- Click on it & the file path will be copied to your clipboard.
- Now open command prompt from start menu or run-command dialog box.
- Type pip install & ctrl+v to paste the file path currently in your clipboard.
- The result would look something like in the image below.
- You do not need to remove the quotes.
- Hit Enter key & wait for the installation to finish.
- You’ll see a success message if the library was successfully installed.
- To cross-check the installation. You can open Python shell & try to import the library you just installed.
- If you don’t see any error then your installation was successful.
But if you receive PIP Install Invalid Syntax Error, then follow the link on how to resolve it.
Checkout the video below to see the steps in action & if you find them useful then please do subscribe to Code Jana YouTube channel.