Blog Froxy | News, Helpful Articles About Using Proxies

Easily Install Python Packages Behind a Proxy with pip

Written by Team Froxy | Jun 12, 2025 9:00:00 AM

There are various scenarios of proxy server use, but proxies are often needed in IT projects, especially when writing custom parsers or building complex web applications or services. In this article, we will explain how to use a proxy with pip, whether it is possible to configure proxies for specific connections or at the level of global environment variables, and how to do this (with detailed instructions). We will also share the list of the most common errors and troubleshooting methods for using pip through a proxy.

Introduction to pip and Proxy Usage

In short, pip is the standard package manager in the Python programming environment. Alternatives to it include conda (for the Anaconda environment), poetry, pipenv (which combines a virtual environment manager, virtualenv, and pip), and buildout (formerly popular for working with large-scale Python projects).

Technically, pip solves the following tasks:

  • Downloads and installs new packages (generally from the public repository PyPI/Python Package Index, official site).
  • Updates are already installed in packages (only through a user command).
  • Manages dependencies (can automatically install additional recommended packages related to the main one).
  • Facilitates convenient removal of unnecessary packages and dependencies.

Proxy servers are intermediary nodes. They are used for various tasks:

  • Redirecting traffic and load balancing.
  • Bypassing faulty nodes and establishing more efficient routes across the Internet.
  • Parallelizing requests and organizing testing (security, performance, etc.).
  • Solving auxiliary tasks with content — data compression, filtering out unwanted content, setting up internal corporate networks, and storage, etc.

In short, a proxy is a tool for organizing alternative Internet routes and managing data streams.

There are different types and kinds of proxies: transparent and anonymous, rotating (back connect scheme) and non-rotating, HTTP/HTTPS, SOCKS, SSH, etc. (depending on supported protocols), residential, mobile, and datacenter (by type of outgoing addresses), caching proxies, with compression, etc. Each proxy type has its use cases and connection features.

For example, when working with parsers, rotating HTTP or SOCKS proxies based on mobile or residential IPs (residential proxies) makes sense. For corporate traffic management tasks, datacenter proxies may be more appropriate.

What is pip and Why Use It with a Proxy?

We must still explain how the Python package manager and a proxy are related. Earlier, we mentioned that pip downloads libraries and code from the PyPI repository. However, this approach can be inconvenient in some instances, such as when:

  • A company uses its own verified code repository. Scripts there may be customized or written from scratch (without general access to the rest of the world).
  • Development is carried out in a location where access to the official code repository is unavailable. For example, access to PyPI website may be blocked by corporate policies or security systems (like antivirus software, firewalls, etc.).

Proxies are required to redirect traffic to the appropriate point. Moreover, a proxy server can perform additional tasks, such as caching static content (including Python script files), checking for viruses and malicious content, and compressing files (to save bandwidth and speed up downloads).

As a result, several issues are solved simultaneously: security is enhanced, traffic and request control are simplified, and content management becomes possible.

Typical Scenarios Where a pip Proxy Is Required

  • Setting up a centralized repository for code and libraries in a corporate environment. Proxies act as the single entry point to this repository (bypassing the standard public PyPI repository).
  • Organizing filtering of unsafe content and scripts is useful, for example, in schools, universities, and other educational institutions. A proxy can filter out viruses and other malicious code at the entrance.
  • Circumventing regional or local restrictions that limit direct access to the PyPI repository. For example, when certain websites or protocols are blocked in a corporate network.
  • Logging access to PyPI for the current project, for better monitoring and identifying bottlenecks.

How to Use pip with Proxy (Quick Start)

The pip package manager can connect to a proxy in several ways, including special command syntax, environment variables, virtual environments, and configuration files.

Below, we’ll go through each way of connecting pip to a proxy in detail.

One-Line pip Install Proxy Syntax

The standard pip syntax looks like this:

pip install <package name>

Call the executable file directly if you haven't added pip to your environment variables. For example, on Windows, it might look like this:

cd "C:\Program Files\Python313\Scripts\"./pip.exe install <package name>

The installation path for pip might differ. In this case, pip was installed in the shared "Program Files" directory, and the Python version is 3.13.

If Python is added to the environment variables without pip, you can use the following command:

python -m pip install <package name>

Instead of the “install” command, you can use others: download (to download the specified package only), uninstall (to remove packages), freeze (to “freeze” the packages), list (to display installed packages), search (to search for packages), etc.

Note: there’s no separate command for updating, but the “install” command has a flag for it:

pip install --upgrade <package name>

The proxy is also specified via a special flag in the pip install command (--proxy). The full command will look like this:

pip install --proxy http://123.455.234.345:3088 <package name>

You should replace the connection data with your own (IP address and port number).

If the proxy uses a domain, the pip connection string would look like this:

pip install --proxy http://proxy-url.com:3088 <package name>

How to Use pip with a Proxy That Requires Authentication

Many rotating proxies require mandatory authentication to secure connections. Connecting pip to a proxy in this case will look like this:

pip install --proxy http://proxy_user:PASSWRD@123.455.234.345:3088 <package name>

You can notice that the structure hasn’t changed a lot — only the authentication parameters have been added.

Naturally, you need to replace the placeholder values with your credentials (provided by your proxy service).

Residential Proxies

Perfect proxies for accessing valuable data from around the world.

Try With Trial $1.99, 100Mb

Persistent pip Proxy Configuration

If you don't want to specify proxy parameters manually every time you use pip, you can try setting the connection details in configuration files or adding them to environment variables.

Let's discuss each approach separately.

pip.conf (Linux/macOS) or pip.ini (Windows) Configuration

Pip can use its configuration files. They are not always stored centrally. It’s better to ask pip directly where it looks for configuration files to avoid guessing.

To do this, type the following command:

pip config -v list

In Windows, configuration files will be picked up from the following directories:

  • Globally (global) — C:\ProgramData\pip\pip.ini
  • Locally (for a specific user) — C:\Users\<YOUR_USERNAME>\pip\pip.ini
  • Another local option (also for a specific user) — C:\Users\<YOUR_USERNAME>\AppData\Roaming\pip\pip.ini
  • For web parsing (site) — C:\Program Files\Python313\pip.ini

The Python installation path may differ in your case, so instead of "C:\Program Files\Python313", it could be another path.

Open the required file and add the following lines:

[global]proxy = http://proxy_user:PASSWRD@123.455.234.345:3088

(with your actual connection data)

If the file doesn’t exist, just create it: right-click in the folder, select "New" → "Text Document," then rename it and change the extension to .ini. You should get the “pip.ini”.

On Linux or macOS, the configuration files have a .conf extension and are located in other directories.

For Linux distributions (in most cases):

  • Global level — /etc/pip.conf. If the OS uses the XDG_CONFIG_DIRS environment variable, then the actual config directory will be determined by its settings (e.g., /etc/xdg/pip/pip.conf).
  • User level — ~/.config/pip/pip.conf (note: hidden folders and files start with a dot, while “~” represents the user's home directory).
  • Website level — $VIRTUAL_ENV/pip.conf (defined at the virtual environment level).

For macOS:

  • Global level — /Library/Application Support/pip/pip.conf.
  • User level — in newer OS versions, $HOME/Library/Application Support/pip/pip.conf, though loading from the old location ($HOME/.config/pip/pip.conf) is still supported, similar to Linux.
  • Website level — $VIRTUAL_ENV/pip.conf (virtual environment config file).

The priority order is assigned to those notes that are defined at the latest level:

  1. First — global level
  2. Second — user level (overrides global if there are duplicate settings)
  3. Third — environment level (overrides user settings if duplicates exist)
  4. Last — command line (overrides environment variables)

pip Proxy Set Up via Environment Variables

In Windows, you can set environment variables through a special interface. Search for "Environment variables" in the system search or open System Properties and click the "Environment Variables" button.

Create the following new variables:

  • Name: HTTP_PROXY
  • Value: http://proxy_user:PASSWRD@123.455.234.345:3088

If the proxy does not require authentication, the format will look something like this:
http://123.455.234.345:3088 or http://proxy-domain.com:3008

Be sure to provide the port number, address, username, and password (the ones above are just examples and do not work).

  • Name: HTTPS_PROXY
  • Value: https://proxy_user:PASSWRD@123.455.234.345:3088

Note: HTTP_PROXY and HTTPS_PROXY are different variables; you must set both.

Using environment variables allows you to configure a system-wide Python proxy (and other script runtime environments).

Instead of using the graphical interface, you can use the command line:

For Windows:

set HTTP_PROXY=http://proxy_user:PASSWRD@123.455.234.345:3088set HTTPS_PROXY=https://proxy_user:PASSWRD@123.455.234.345:3088

For Linux

export http_proxy=http://proxy_user:PASSWRD@123.455.234.345:3088export https_proxy=https://proxy_user:PASSWRD@123.455.234.345:3088

If you want to set a list of exceptions (sites that should bypass the proxy), list them in the no_proxy variable. For example:

set NO_PROXY=example.com,site123.org,127.0.0.1

To remove a variable in Linux, use the unset command:

unset HTTP_PROXY

In Windows, it's easier to set an "empty" proxy to effectively remove it:

set HTTP_PROXY=

Or, you can fully reset proxy settings with administrator rights:

netsh winhttp reset proxy

Pip and Proxies via the «Config» Command

Recently, Python introduced a CLI interface for managing pip settings.

You can now define global, user-level, and virtual environment-specific configurations directly from the command line. The syntax is not dependent on the platform.

Here is how the command to install a proxy will look on the global level:

pip config set global.proxy http://proxy.host:1234

or

pip config set global.proxy http://login:pass@proxy.host:1234

(if authorization is used with login and password)

Here is how settings are defined on the user level:

pip config set user.proxy http://login:pass@proxy.host:1234

And here is how they are defined for the «site» level (environment variables):

pip config set site.proxy http://login:pass@proxy.host:1234

Pip and Proxies in Virtual Environments and Tools

You can set or change the environment variable directly within Python scripts like this:

PIP_PROXY = http://login:pass@proxy.host:1234

This will be a complete equivalent for running the command «pip --proxy http://login:pass@proxy.host:1234».

Don't forget to use the actual credentials to connect to your proxy.

If you need to install a package using pip through a proxy for a specific virtual environment, use the following syntax:

C:\Users\<YOUR_NAME>\myvenv\Scripts\pip install --proxy=http://proxy-user:passwd@proxy_address:1234 virtualenv

In other words, you need to call the pip executable directly within your virtual environment.

If the direct path doesn't work, navigate to the correct directory first:

cd “C:\Users\<YOUR_NAME>\myvenv\Scripts\pip”./pip.exe install --proxy=http://proxy-user:passwd@proxy_address:1234 <package name>

You can also configure general proxy settings for the current virtual environment. This is done via the standard environment variables we reviewed earlier (HTTP_PROXY and HTTPS_PROXY):

  • On Linux — «export http_proxy=http://proxyserver:port» and «export https_proxy=https://proxyserver:port».
  • On Windows — «set http_proxy=http://proxyserver:port» and «set https_proxy=https://proxyserver:port».

Troubleshooting pip Proxy

Some of the most complex configuration errors involve proxies being defined in different config files, for other users and at various access levels (globally, in environment variables, etc.). It can be pretty challenging to figure out what is set and where.

A centralized proxy configuration mechanism may be used in large corporate networks, often involving NTLM authentication (also used in proxy servers like NTLMAPS and CNTLM).

When running pip, misconfigured settings can often be quickly fixed by specifying the proxy parameters directly in the command line. These settings have the highest priority.

However, simply specifying the proxy address and port is not enough. Other configuration options can also cause errors.

Common Errors: Timeouts, SSL, Authentication Failures

PyPI Repository Unavailable

This is rare but quite possible. To verify if PyPI works, connect to it directly (without a proxy) or through another (known-working) proxy.

pip Connect via Proxy Returns a Timeout Error

At the very least, you should verify that the proxy is available and functions correctly (and that you haven't mistyped your username or password). You can check this using command-line tools like curl or wget (more on that below).

It also makes sense to override the default timeout setting — just in case it's been set too low somewhere in your config files (the system default is 15 seconds). For example:

pip install --proxy http://123.455.234.345:3088 --timeout=60 <package name>

In this example, we’ve set the timeout to 60 seconds.

Authentication Error (Error 407)

If the proxy is accessible, but the error only occurs when calling from your Python script, it's likely due to special characters in your username or password.

You need to re-encode special characters. For example:

  • @ – %40
  • : – %3A
  • # – %23

Verification Error (Unsafe SSL Certificates)

The most suitable approach is to add the correct security certificates using the --cert=/path/to/certificate/cert.pem option. This error usually occurs when using a third-party package index and authentication falls back to the default SSL (for pypi.org). Naturally, the certificate will be flagged as invalid. You must download and install the SSL certificate for the chosen package index to resolve this.

If you can’t access the correct SSL certificate, you can’t add it — but there’s a workaround.

A temporary workaround is to mark the host address that causes the error as trusted using the --trusted-host flag:

pip install --trusted-host your-index.org --proxy http://123.455.234.345:3088 <package name>

Diagnosing with Detailed Output and curl/wget

The simplest option is to access the website using the curl utility and print all warnings and information to the console:

curl -I https://pypi.org --proxy http://proxy-user:passwd@proxyserver.com:3038

You may need to download and install the utility manually (from the official curl website) on Windows. Running the script is a bit more complex. First, extract the program into a folder, then navigate to that folder:

cd "C:\path\to\curl\bin\"curl.exe -I https://pypi.org --proxy http://proxy-user:passwd@proxyserver.com:3038

By default, WGET is unavailable in Windows, so it must be downloaded and installed separately.

The syntax for accessing websites through a proxy is as follows:

wget https://pypi.org -e use_proxy=yes -e http_proxy=proxy-user:passwd@proxyserver.com:3038

Alternatively, you can define the proxy at the environment variable level (see the instructions above) and access websites without additional options:

wget https://pypi.org

Standard debugging for the pip package manager is set using the -v parameter. The more v's you add, the more detailed the log output becomes:

  • Detailed output – «pip install -v--proxy http://123.455.234.345:3088 <package name>»
  • More detailed – «pip install -vv--proxy http://123.455.234.345:3088 <package name>»
  • Maximum details – «pip install -vvv--proxy http://123.455.234.345:3088 <package name>»
Mobile Proxies

Premium mobile IPs for ultimate flexibility and seamless connectivity.

Try With Trial $1.99, 100Mb

Additional Tips for Using pip with a Proxy

Proxy connection parameters — especially logins and passwords — should be considered sensitive information. Because of this, storing pip proxy credentials directly in your script code is not considered secure. It might be possible in a single-developer scenario (e.g., a personal or fan project), but it's risky in larger teams or when scripts are shared across an organization.

In this case, we recommend defining proxy connection at the environment variable or configuration level (ini/config files).

However, another problem emerges: the more proxies you use in a project, the more complicated it will be to manage them.

An elegant (but paid) solution is available here — using a rotating proxy service like Froxy. You just need to create a separate proxy filter (or a port), grant connection credentials to a user, and then manage the parameters of choosing output addresses via a convenient dashboard. Filters or ports no longer needed are easily disabled and deleted (e.g., if an employee leaves or the proxy for a particular service is obsolete).

Conclusion and Recommendations

Pip is a powerful built-in tool for managing Python libraries. This package manager works with proxies out of the box, adding flexibility and functionality.

Proxies can be configured via CLI, environment variables, or configuration files. A special console utility for pip settings is pip config.

However, it is not enough just to set up pip. You also need quality proxies. You can pick reliable rotating residential, mobile, and server proxies from us. Froxy offers over 10 million IPs from more than 200 countries, targeting cities and mobile operators. Pricing is based on traffic used.