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.

Error when adding package: EmptyConstraint instance has no attribute 'min'

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).

Issue

Hi! This is my first time attempting to use poetry. I created a new empty project with this command:

$ poetry new example

Then, from within the example directory, I attempt to add the jupyter package:

$ poetry add jupyter
Using version ^1.0 for jupyter

Updating dependencies
Resolving dependencies... (4.0s)

[AttributeError]
EmptyConstraint instance has no attribute 'min'

add [-D|--dev] [--git GIT] [--path PATH] [-E|--extras EXTRAS] [--optional] [--python PYTHON] [--platform PLATFORM] [--allow-prereleases] [--dry-run] [--] <name> (<name>)...

Verbose output is contained within the gist linked above. I am able to add other packages without apparent error. Happy to provide additional info.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:28 (7 by maintainers)

github_iconTop GitHub Comments

13reactions
glencairncommented, Mar 3, 2021

I’m experiencing this same issue with Poetry 1.1.4 when trying to install certain packages. I was able to get around the issue following a similar approach that @bnoctis and @agilgur5 detailed above. However, for a more recent vendorized install, the file I had to modify was ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/packages/dependency.py (where python3.8 is my active interpreter).

Here’s a diff of the modifications I made, hopefully others find this useful:

diff --git a/tmp.py b/Users/user/.poetry/lib/poetry/_vendor/py3.8/poetry/core/packages/dependency.py
index e118794..6f97002 100644
--- a/tmp.py
+++ b/Users/user/.poetry/lib/poetry/_vendor/py3.8/poetry/core/packages/dependency.py
@@ -9,6 +9,7 @@ from poetry.core.semver import Version
 from poetry.core.semver import VersionConstraint
 from poetry.core.semver import VersionRange
 from poetry.core.semver import VersionUnion
+from poetry.core.semver import EmptyConstraint
 from poetry.core.semver import parse_constraint
 from poetry.core.version.markers import AnyMarker
 from poetry.core.version.markers import parse_marker
@@ -291,6 +292,8 @@ class Dependency(PackageSpecification):
                 name = "python_full_version"
 
             marker = '{} == "{}"'.format(name, constraint.text)
+        elif isinstance(constraint, EmptyConstraint):
+            marker = ''
         else:
             if constraint.min is not None:
                 min_name = name

System: MacOS Poetry: 1.1.4

9reactions
elicutlercommented, Aug 19, 2021

I had to edit ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/version/markers.py

from poetry.core.packages.constraints.empty_constraint import EmptyConstraint

and line 281 in the definition of validate(self, environment), added:

if isinstance(self._constraint, EmptyConstraint):
    return True

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when adding package: EmptyConstraint instance has no ...
This fails with the same AttributeError as above if I instead use pyenv local 2.7.10 . I can install jupyter directly using pip...
Read more >
'EmptyConstraint' object has no attribute 'min' with pytest and ...
'EmptyConstraint' object has no attribute 'min' with pytest and Python 2.7.
Read more >
Python: instance has no attribute - Stack Overflow
the error means the class Residues doesn't have a function call atoms. The solution could be as follows:
Read more >
Pyomo Documentation - Read the Docs
The standard utility for installing Python packages is pip. ... ERROR: AttributeError: 'IndexedVar' object has no attribute 'is_binary'.
Read more >
User's Manual for CPLEX - FTP Directory Listing - IBM
This guide contains important information on the procedures and practices followed in the service and support of your IBM products.
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