question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

poetry fails to find packages in private repositories - depends on venv

See original GitHub issue
  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: ubuntu 19.10
  • Poetry version: 1.0.5

Issue

It seems that poetry fails to find the package from a private repository (both with nginx + autoindex and pypiserver) if virtualenv is created by poetry or by python -m venv. It finds it if the virtualenv is build with virtualenvwrapper.

I was trying to add package thx-nonamespace from repository pypi.thux.dev in a package created with poetry new bianco after adding support for a personal repository:

[tool.poetry]
name = "bianco"
version = "0.1.0"

[[tool.poetry.source]]
name = "dev"
url = "https://pypi.thux.dev/simple/"

and the error message is:

$ poetry add thx-nonamespace
Using version ^0.1.0 for thx-nonamespace

Updating dependencies
Resolving dependencies... (0.6s)


Package operations: 1 install, 0 updates, 0 removals

  - Installing thx-nonamespace (0.1.0)

[EnvCommandError]
Command ['/tmp/bianco/lotest/bin/pip', 'install', '--no-deps', '--index-url', 'https://thux:TFCxdr@pypi.thux.dev/simple', '--extra-index-url', 'https://pypi.org/simple/', 'thx-nonamespace==0.1.0'] errored with the following return code 1, and output: 
Looking in indexes: https://pypi.thux.dev/simple, https://pypi.thux.dev/simple/, https://pypi.org/simple/
Looking in links: https://pypi.thux.it
Collecting thx-nonamespace==0.1.0
Could not install packages due to an EnvironmentError: 404 Client Error: Not Found for url: https://pypi.org/simple/thx-nonamespace/

poetry start correctly detecting the existing release of pkg thx-nonamespace but then tries to downloading it from pypi.org and clearly fails to find it. This happens both with poestry’s navive virtualenv and with virtualenv created with python -m venv.

Everything works correctly if I use a virtualenv build with virtualenvwrapper:

sandro@bluffx:/tmp/bianco$ mkvirtualenv junk-bianco
Running virtualenv with interpreter /usr/bin/python3.7
Using base prefix '/usr'
/usr/lib/python3/dist-packages/virtualenv.py:1090: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
New python executable in /home/sandro/.virtualenvs/junk-bianco/bin/python3.7
Also creating executable in /home/sandro/.virtualenvs/junk-bianco/bin/python
Please make sure you remove any previous custom paths from your /home/sandro/.pydistutils.cfg file.
Installing setuptools, pkg_resources, pip, wheel...done.
virtualenvwrapper.user_scripts creating /home/sandro/.virtualenvs/junk-bianco/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/sandro/.virtualenvs/junk-bianco/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/sandro/.virtualenvs/junk-bianco/bin/preactivate
virtualenvwrapper.user_scripts creating /home/sandro/.virtualenvs/junk-bianco/bin/postactivate
virtualenvwrapper.user_scripts creating /home/sandro/.virtualenvs/junk-bianco/bin/get_env_details
(junk-bianco) sandro@bluffx:/tmp/bianco$ poetry add thx-nonamespace
Using version ^0.2.0 for thx-nonamespace

Updating dependencies
Resolving dependencies... (0.7s)


Package operations: 12 installs, 0 updates, 0 removals

  - Installing zipp (3.1.0)
  - Installing importlib-metadata (1.5.0)
  - Installing pyparsing (2.4.6)
  - Installing six (1.14.0)
  - Installing attrs (19.3.0)
  - Installing more-itertools (8.2.0)
  - Installing packaging (20.3)
  - Installing pluggy (0.13.1)
  - Installing py (1.8.1)
  - Installing wcwidth (0.1.8)
  - Installing pytest (5.3.5)
  - Installing thx-nonamespace (0.2.0)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sandrodencommented, Apr 29, 2020

Good news: I have now a situation that works. The last step was to use a private repo using pypiserver rather than the private repository I used for years that just uses nginx + autoindex. I think this is acceptable but needs to be reported in the documentation.

When I tested the different setup I didn’t realize that poetry.lock holds the pyproject.toml configuration and particularly the sources. Poetry adds a warning that poetry.lock needs an update, but I may have not put enough attention on it so that I thought it worked with both repositories but I was just working with the same one (pypiserver).

So, the working situation for me passes through these steps:

  1. the private repo pypiserver (rather than nginx + autoindex
  2. pip run pip inistall --upgrade pip (@mrosales suggests also setuptools and wheel)
  3. (clearly) add the repo in pyproject.toml: [[tool.poetry.source]]
0reactions
neersightedcommented, Oct 5, 2022

Closing this as it doesn’t reproduce on 1.2.x (and indeed, with the new installer Poetry downloads packages, instead of pip).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Repositories | Documentation | Poetry - Python dependency ...
Repositories Poetry supports the use of PyPI and private repositories for discovery of packages as well as for publishing your projects.
Read more >
Why you should use Poetry instead of Pip or Conda for Python ...
This happens because Pip will search for and install libraries from only the private repository if the --index-url option is used, and search ......
Read more >
Installing Private Python Packages - Read the Docs
Read the Docs uses pip to install your Python packages. If you have private dependencies, you can install them from a private Git...
Read more >
How to add a private repository using poetry? - Stack Overflow
poetry update Updating dependencies Resolving dependencies... (0.9s) RepositoryError 401 Client Error: Unauthorized for url: ...
Read more >
Poetry: Dependency Management for Python - PyPI
will fail with this error: Could not find a version that matches pbr!=0.7,!=2.1.0,<1.0,>=0.6,>=2.0.0. while Poetry will get you the right set of packages:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found