Using devpi to build pypi private server in Intranet

Keywords: pip Windows Python Nginx

Install devpi


devpi consists of three components:

  • Devpi server: provides image and cache functions, deploys in the DMZ area of the enterprise, and improves the efficiency of downloading python package
  • Devpi Web: provide web interface and query function
  • Devpi client: command line tool, providing package upload and other functions


# If devpi server does not work with the Internet, you can install it by setting up an agent
# pip --proxy http://proxy_server:3128 install -q -U devpi-server

pip install -q -U devpi-server
devpi-server --version

Initialization and initial start-up

devpi-server --init
devpi-server --start


pip install -i http://localhost:3141/root/pypi/ simplejson
pip uninstall -y simplejson
easy_install -i http://localhost:3141/root/pypi/+simple/ simplejson
pip uninstall -y simplejson


pip install -q -U devpi-web
devpi-server --stop
devpi-server --recreate-search-index
devpi-server --start
pip search --index http://localhost:3141/root/pypi/ devpi-client

Common commands

devpi-server --init
devpi-server --start
devpi-server --stop
devpi-server --status
devpi-server --log

devpi behind proxy

export http_proxy="http://proxy_server:3128"
export https_proxy="http://proxy_server:3128"
export no_proxy="localhost,,"
devpi-server --start

nginx reverse proxy

# http block
upstream {
    keepalive 16;

# server block
location ~ /(root|\+search) {
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

Client settings


# Linux:       $HOME/.pip/pip.conf
# Windows 7:   C:\ProgramData\pip\pip.ini
# windows xp:  C:\Documents and Settings\All Users\Application Data\pip\pip.ini
# or use environment variable PIP_CONFIG_FILE to specify location

# please replace to your REAL domain name

index-url =


index =


# $HOME/.pydistutils.cfg:
index_url =

Reference resources

Author: Pastoral w
Source: Jianshu
The copyright belongs to the author. For commercial reprint, please contact the author for authorization. For non-commercial reprint, please indicate the source.

Posted by d_barszczak on Thu, 30 Apr 2020 16:57:21 -0700