Poetry: Unable to add packages from a private registry

Created on 24 Feb 2020  路  5Comments  路  Source: python-poetry/poetry

  • [x] I am on the latest Poetry version.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: Pop_OS! 19.10

  • Poetry version: 1.0.3
  • Link of a Gist with the contents of your pyproject.toml file: N/A

Issue

Poetry fails to install a package from a private repository.

[EnvCommandError]
Command ['/home/remco/.cache/pypoetry/virtualenvs/[venv]-py3.7/bin/pip', 'install', '--no-deps', '--index-url', 'https://[username]:@pypi.fury.io/[org]', '--extra-index-url', 'https://pypi.org/', 'dc-patsy==0.1.3'] errored with the following return code 1, and output: 
Looking in indexes: https://pypi.fury.io/[org], https://pypi.org/
Collecting [package]==0.1.3
Could not install packages due to an EnvironmentError: 404 Client Error: Not Found for url: https://pypi.org/[package]/

Traceback (most recent call last):
  File "/home/remco/.local/pipx/venvs/poetry/lib/python3.7/site-packages/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/home/remco/.local/pipx/venvs/poetry/lib/python3.7/site-packages/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/home/remco/.local/pipx/venvs/poetry/lib/python3.7/site-packages/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/home/remco/.local/pipx/venvs/poetry/lib/python3.7/site-packages/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/home/remco/.local/pipx/venvs/poetry/lib/python3.7/site-packages/poetry/console/commands/install.py", line 63, in handle
    return_code = installer.run()
  File "/home/remco/.local/pipx/venvs/poetry/lib/python3.7/site-packages/poetry/installation/installer.py", line 74, in run
    self._do_install(local_repo)
  File "/home/remco/.local/pipx/venvs/poetry/lib/python3.7/site-packages/poetry/installation/installer.py", line 286, in _do_install
    self._execute(op)
  File "/home/remco/.local/pipx/venvs/poetry/lib/python3.7/site-packages/poetry/installation/installer.py", line 302, in _execute
    getattr(self, '_execute_{}'.format(method))(operation)
  File "/home/remco/.local/pipx/venvs/poetry/lib/python3.7/site-packages/poetry/installation/installer.py", line 327, in _execute_install
    self._installer.install(operation.package)
  File "/home/remco/.local/pipx/venvs/poetry/lib/python3.7/site-packages/poetry/installation/pip_installer.py", line 97, in install
    self.run(*args)
  File "/home/remco/.local/pipx/venvs/poetry/lib/python3.7/site-packages/poetry/installation/pip_installer.py", line 123, in run
    return self._env.run_pip(*args, **kwargs)
  File "/home/remco/.local/pipx/venvs/poetry/lib/python3.7/site-packages/poetry/utils/env.py", line 843, in run_pip
    return self._run(cmd, **kwargs)
  File "/home/remco/.local/pipx/venvs/poetry/lib/python3.7/site-packages/poetry/utils/env.py", line 1071, in _run
    return super(VirtualEnv, self)._run(cmd, **kwargs)
  File "/home/remco/.local/pipx/venvs/poetry/lib/python3.7/site-packages/poetry/utils/env.py", line 875, in _run
    raise EnvCommandError(e, input=input_)

The following command does work:

poetry run pip install --no-deps --index-url https://[username]:@pypi.fury.io/[org] [package]==0.1.3

I have manually modified the lockfile, so it refers to the correct registry for this package. However, poetry still adds https://pypi.org/ as an --extra-index-url.

I believe the fix would be to remove the default --extra-index-url. I believe this conflicts with the idea of having a lockfile anyway.

This is similar to #1942, but that issue describes a bug for poetry add instead of poetry install, and the workaround described there doesn鈥檛 work for me.

Bug

All 5 comments

I'm on 1.0.5 and experiencing a similar problem. I can lock, but I can't use poetry install if a private registry is involved.

I was eventually able to work around it by adding the pypi.org/simple in a 2nd tool.poetry.source section, and properly marking them even though that's _supposed_ to be the default behavior:

[[tool.poetry.source]]
name = "myrepo"
url = "https://myrepo.com/simple"
default = true


[[tool.poetry.source]]
name = "pypi.org"
url = "https://pypi.org/simple"
secondary = true

i.e.: the default and secondary were required, else install would complain.

I commented on this other issue: https://github.com/python-poetry/poetry/issues/2178#issuecomment-604057579

I had a similar problem and it seemed to come from the fact that my system pip was outdated. poetry install began working after running poetry run pip install -U pip setuptools wheel to upgrade my packaging utilities.

I think that there needs to be a way to specify a pip version requirement for poetry install

@jonapich I am facing (what seems to be) the same error.
I tried your work around with adding the default/secondary attribute on the tool.poetry.source sections.
What I get is the Resolving dependencies is running for a long time (up to 15 mins, which I killed it).

To whoever will be working on this, if there is info I can provide that might help, please let me know.

@billkouts That happened to me a while ago when trying to resolve a very old boto3 version. Adding some constraints to the packages made everything much faster.

@jonapich thnx for this I will give it a try

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Euphorbium picture Euphorbium  路  3Comments

tonysyu picture tonysyu  路  3Comments

thmo picture thmo  路  3Comments

jeremy886 picture jeremy886  路  3Comments

probablykasper picture probablykasper  路  3Comments