Install Python Library Offline Including Error Handling

This guide will show you how to install the Python library offline and handle errors during installation. Python, the versatile, high-level programming language, offers its developers an immense range of libraries. These libraries, pre-written pieces of code solving specific tasks, significantly improve developers’ productivity by eliminating the need to code everything from scratch. However, not every system we work on might have an internet connection, requiring us to install these libraries offline.

Affiliate: Experience limitless no-code automation, streamline your workflows, and effortlessly transfer data between apps with

Download Before We Install Python Library Offline

We first install the Python library offline by downloading the desired library. For example, we want to download the “requests” library. The first step would be to create a folder to store our downloaded library. You could create this anywhere, but for our example, let’s go with the following:


We need to use the Command Prompt (cmd.exe) to download the library. After downloading, we’ll be able to install the Python library offline. You can run Command Prompt from the Start menu search or press [Win] + [R], typing “cmd,” and pressing [Enter]. Once the Command Prompt is open, navigate to the folder you created using the cd (Change Directory) command:

cd "D:\libraries\requests"

The quotes are crucial if there are spaces in the folder names in your directory path.
Once you are in the folder, you need to run Python’s package installer “pip.exe” with the download parameter as follows:

pip download requests

This command will download the “requests” library and its dependencies into your specified folder. After the process finishes, you will see several “.whl” or “.tar.gz” files in the folder.

Simplifying the Library Installation Process

After downloading, we simplify the install python library offline process by creating a Command Prompt file, “requests_install.cmd”, in the same location. The file path would be:


This file will contain the command to install the package:

pip install --no-index --find-links "D:\libraries\requests" requests

In this command:
pip install: installs the package using Python’s package installer pip.
–no-index: The option informs pip not to search for packages on the Python Package Index (, as by default, pip installs packages from this online repository.
–find-links “D:\libraries\requests”: The option guides pip to the location where it can find the package files.
pause: This CMD command pauses script execution until a user presses any key. We need it mainly to see the execution process and to observe any errors before the CMD window closes.

These parameters are the most important ones when you want to install the Python library offline.

It’s crucial to note that the directory path should not contain a separator at the end, such as:


In this case, the slash character serves as an escape character and would subsequently escape the double quotes, leading to an error.

For more convenience, you can also use a relative path with Command Prompt’s special variable:


This variable will contain the current directory’s path, including the last path separator at the end:

pip install --no-index --find-links "%~dp0requests" requests

Some antivirus software might raise concerns against ‘pip.exe’, as it is a script housed in an EXE file. To address this, you can directly run the script with ‘python.exe’:

python -m pip install --no-index --find-links "%~dp0requests" requests

In this case, the ‘-m’ option allows the execution of a script located in Python’s installation folder inside the “Scripts” folder.

If you need to upgrade an older version of the library, you can use the “–upgrade” option:

python -m pip install --upgrade --no-index --find-links "%~dp0requests" requests

Handle Errors While You Install Python Library Offline

At this stage, you can take the “libraries” folder to the computer without an internet connection to install the Python library offline. As you remember, this folder contains the CMD installation file and the “requests” folder with the requests library and its dependencies.

While executing the CMD file, you can encounter several errors.

Error: You must give at least one requirement to install

ERROR: You must give at least one requirement to install (maybe you meant "pip install D:\libraries\requests" requests"?)

When you install the Python library offline, this error will arise when using quotes around the library folder path containing spaces. At the same time, the last character is a backslash in the path, as we mentioned earlier. This error happens because “pip” interprets the backslash as an escape character, which escapes the double quotes character which results in pip thinking that the folder he should look in is:


Which, of course, doesn’t exist. The message means that the library “requests” from the end of the command line don’t exist in the location that comes with the “–find-links” option.

Error: Could not find the requirement setuptols

Processing d:\libraries\pymsgbox\pymsgbox-1.0.9.tar.gz
  Installing build dependencies ... error
  error: subprocess-exited-with-error
  x pip subprocess to install build dependencies did not run successfully.
  | exit code: 1
   -> [3 lines of output]
      Looking in links: d:\libraries\pymsgbox
      ERROR <This particular Line>: Could not find a version that satisfies the requirement setuptools>=40.8.0 (from versions: none)
      ERROR: No matching distribution found for setuptools>=40.8.0
      [end of output]

You will probably not get this error when you install the Python library offline of “requests”, but we did encounter it with “pymsgbox 1.0.9”. The “Could not find a version that satisfies the requirement setuptools” error means that pip couldn’t find the “setuptools” library version at least 40.8.0 with your current Python setup. But the latest versions of Python already come with the setuptools package preinstalled.

By default, pip uses Python’s isolated environment without libraries to install the Python library offline. To force pip, use the regular environment with the setuptools package – use the option “–no-build-isolation”. Now your CMD should look like this:

python -m pip install --upgrade --no-index --no-build-isolation --find-links "%~dp0requests" requests

Error: Invalid command ‘bdist_wheel’

Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
  x Preparing metadata (pyproject.toml) did not run successfully.
  | exit code: 1
   -> [12 lines of output]
running dist_info
creating C:\Users\User\AppData\Local\Temp\pip-modern-metadata-nh\PyMsgBox.egg-info
writing C:\Users\User\AppData\Local\Temp\pip-modern-metadata-nh\PyMsgBox.egg-info\PKG-INFO
writing dependency_links to C:\Users\User\AppData\Local\Temp\pip-modern-metadata-nh\PyMsgBox.egg-info\dependency_links.txt
writing top-level names to C:\Users\User\AppData\Local\Temp\pip-modern-metadata-nh\PyMsgBox.egg-info\top_level.txt
writing manifest file 'C:\Users\User\AppData\Local\Temp\pip-modern-metadata-nh\PyMsgBox.egg-info\SOURCES.txt'
reading manifest file 'C:\Users\User\AppData\Local\Temp\pip-modern-metadata-nh\PyMsgBox.egg-info\SOURCES.txt'
reading manifest template ''
warning: no files found matching '*.py' under directory 'pymsgbox'
writing manifest file 'C:\Users\User\AppData\Local\Temp\pip-modern-metadata-nh\PyMsgBox.egg-info\SOURCES.txt'
creating 'C:\Users\User\AppData\Local\Temp\pip-modern-metadata-nh\PyMsgBox-1.0.9.dist-info'
error: invalid command 'bdist_wheel'

The “invalid command ‘bdist_wheel'” error occurs when you install the Python library offline, and the wheel library is non-existent on your Python installation. So, you need to install the “wheel” package before installing the main package.

Download the wheel package as we did at the beginning of this guide and put its package files and dependencies in the same folder as your installation package. You may also put it in a separate folder, call it “wheel,” and add another line in our installation CMD so it comes before the main package installation.

In case you want to put it in the same folder as your main package:

python -m pip install --upgrade --no-index --no-build-isolation --find-links "%~dp0requests" wheel
python -m pip install --upgrade --no-index --no-build-isolation --find-links "%~dp0requests" requests

In case you want to put it in a separate “wheel” folder:

python -m pip install --upgrade --no-index --no-build-isolation --find-links "%~dp0wheel" wheel
python -m pip install --upgrade --no-index --no-build-isolation --find-links "%~dp0requests" requests

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.