Nexus repository manager as pip local server not working properly

jaysonpryde picture jaysonpryde · Jan 23, 2017 · Viewed 27.8k times · Source

A local nexus server has been setup as our pip local server. I'm trying to install a sample/test class (inherits) using the said local server. Uploading to the local server is successful, but installing using this command:

pip install -i http://<nexus-ip>:8081/repository/pypi-all/pypi inherits

Resulted to this:

  Could not find a version that satisfies the requirement inherits 
  (from versions: )
  No matching distribution found for inherits

I also tried these commands, but the results are the same:

pip install inherits
pip install -i http://<nexus-ip>:8081/repository/pypi-all/pypi inherits-0.1
pip install -i http://<nexus-ip>:8081/repository/pypi-all/pypi inherits==0.1

Here're the contents of my ~/.pypirc:

[distutils]
index-servers =
    nexus
    pypi

[nexus]
username: my-username
password: mypassword
repository: http://<nexus-ip>:8081/nexus/repository/pypi-internal/

[pypi]
...

Here're the contents my ~/.config/pip/pip.conf

[global]
index = http://<nexus-ip>:8081/repository/pypi-all/pypi
index-url = http://<nexus-ip>:8081/repository/pypi-all/simple

As mentioned, uploading using below command is successful:

python setup.py sdist upload -r nexus

Response from the nexus server is here (i.e. signifies upload was successfull):

creating inherits-0.1
creating inherits-0.1/inherits
creating inherits-0.1/inherits.egg-info
copying files to inherits-0.1...
copying setup.cfg -> inherits-0.1
copying setup.py -> inherits-0.1
copying inherits/__init__.py -> inherits-0.1/inherits
copying inherits/addmult.py -> inherits-0.1/inherits
copying inherits/inherits.py -> inherits-0.1/inherits
copying inherits/subdiv.py -> inherits-0.1/inherits
copying inherits.egg-info/PKG-INFO -> inherits-0.1/inherits.egg-info
copying inherits.egg-info/SOURCES.txt -> inherits-0.1/inherits.egg-info
copying inherits.egg-info/dependency_links.txt -> inherits-0.1/inherits.egg-info
copying inherits.egg-info/top_level.txt -> inherits-0.1/inherits.egg-info
Writing inherits-0.1/setup.cfg
Creating tar archive
removing 'inherits-0.1' (and everything under it)
running upload
Submitting dist/inherits-0.1.tar.gz to http://<nexus-ip>:8081/nexus/repository/pypi-internal/
Server response (200): OK

Contents of the setup.py are the basic details:

#!/usr/bin/env python

import os
import sys

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

requires = []

setup( 
    name = "inherits",
    packages = ["inherits"],
    version = '0.1',
    description = 'Example inherits package',
    #url = "",
    #download_url = "",
    author = "Jayson Pryde",
    classifiers = [],
)

Any ideas on how to resolve this and make the pip install work? Thanks in advance!

Answer

jaysonpryde picture jaysonpryde · Jan 30, 2017

In case someone has encountered the same issue and is interested for a solution, here are two things I did.

1. Execute pip using this:

pip install inherits -i http://<nexus-ip>:8081/nexus/repository/pypi-all/simple -v --trusted-host <nexus-ip>

The -v and --trusted-host parameters are optional

2. Move your ~/.config/pip/pip.conf to ~/.pip/pip.conf and execute:

pip install inherits -v —trusted-host <nexus-ip>

Only challenge encountered with #2 is pip will always connect to the nexus server. So in case I want to connect to pypi.org, I have to rename the pip.conf first.

Hope this helps someone!