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.

AttributeError: can't set attribute on "poetry install"

See original GitHub issue

I manually solved #4333. Now I’m running into a more puzzling 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: MacOS
  • Poetry version: 1.2.0a
  • Link of a Gist with the contents of your pyproject.toml file:
[tool.poetry]
name = "my_project"
version = "0.1.0"
description = "Poetry plugin to setup automated release"
authors = ["Sunds team <sunds@google.com>"]

[tool.poetry.dependencies]
python = "^3.7"

Issue

I’m trying to install the above dummy toml.

poetry install  -vvv

It should be trivial to execute. However, this crash with:

   2  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/poetry/mixology/version_solver.py:394 in _choose_package_version
       392β”‚             version = locked
       393β”‚ 
     β†’ 394β”‚         version = self._provider.complete_package(version)
       395β”‚ 
       396β”‚         conflict = False

   1  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/poetry/puzzle/provider.py:702 in complete_package
       700β”‚             clean_dependencies.append(dep)
       701β”‚ 
     β†’ 702β”‚         package.requires = clean_dependencies
       703β”‚ 
       704β”‚         return package

  AttributeError

  can't set attribute

  at /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/poetry/packages/dependency_package.py:38 in __setattr__
       34β”‚     def __setattr__(self, key: str, value: Any) -> None:
       35β”‚         if key in {"_dependency", "_package"}:
       36β”‚             return super().__setattr__(key, value)
       37β”‚ 
    β†’  38β”‚         setattr(self._package, key, value)
       39β”‚ 
       40β”‚     def __str__(self) -> str:
       41β”‚         return str(self._package)
       42β”‚ 
Full stacktrace. Click to expand!
Loading configuration file /Users/epot/Library/Application Support/pypoetry/config.toml
Using virtualenv: /Users/epot/Library/Caches/pypoetry/virtualenvs/my-project-e_gpocHn-py3.8
Updating dependencies
Resolving dependencies...
   1: fact: my-project is 0.1.0
   1: derived: my-project
   1: Version solving took 0.012 seconds.
   1: Tried 1 solutions.

  Stack trace:
  16  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cleo/application.py:330 in run
       328β”‚ 
       329β”‚             try:
     β†’ 330β”‚                 exit_code = self._run(io)
       331β”‚             except Exception as e:
       332β”‚                 if not self._catch_exceptions:

  15  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/poetry/console/application.py:167 in _run
       165β”‚         self._load_plugins(io)
       166β”‚ 
     β†’ 167β”‚         return super()._run(io)
       168β”‚ 
       169β”‚     def _configure_io(self, io: IO) -> None:

  14  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cleo/application.py:425 in _run
       423β”‚                 io.set_input(ArgvInput(argv))
       424β”‚ 
     β†’ 425β”‚         exit_code = self._run_command(command, io)
       426β”‚         self._running_command = None
       427β”‚ 

  13  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cleo/application.py:467 in _run_command
       465β”‚ 
       466β”‚         if error is not None:
     β†’ 467β”‚             raise error
       468β”‚ 
       469β”‚         return event.exit_code

  12  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cleo/application.py:451 in _run_command
       449β”‚ 
       450β”‚             if event.command_should_run():
     β†’ 451β”‚                 exit_code = command.run(io)
       452β”‚             else:
       453β”‚                 exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED

  11  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cleo/commands/base_command.py:118 in run
       116β”‚         io.input.validate()
       117β”‚ 
     β†’ 118β”‚         status_code = self.execute(io)
       119β”‚ 
       120β”‚         if status_code is None:

  10  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cleo/commands/command.py:85 in execute
        83β”‚ 
        84β”‚         try:
     β†’  85β”‚             return self.handle()
        86β”‚         except KeyboardInterrupt:
        87β”‚             return 1

   9  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/poetry/console/commands/install.py:75 in handle
        73β”‚         self._installer.verbose(self._io.is_verbose())
        74β”‚ 
     β†’  75β”‚         return_code = self._installer.run()
        76β”‚ 
        77β”‚         if return_code != 0:

   8  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/poetry/installation/installer.py:112 in run
       110β”‚         local_repo = Repository()
       111β”‚ 
     β†’ 112β”‚         return self._do_install(local_repo)
       113β”‚ 
       114β”‚     def dry_run(self, dry_run: bool = True) -> "Installer":

   7  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/poetry/installation/installer.py:252 in _do_install
       250β”‚             )
       251β”‚ 
     β†’ 252β”‚             ops = solver.solve(use_latest=self._whitelist)
       253β”‚         else:
       254β”‚             self._io.write_line("Installing dependencies from lock file")

   6  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/poetry/puzzle/solver.py:99 in solve
        97β”‚         with self._provider.progress():
        98β”‚             start = time.time()
     β†’  99β”‚             packages, depths = self._solve(use_latest=use_latest)
       100β”‚             end = time.time()
       101β”‚ 

   5  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/poetry/puzzle/solver.py:270 in _solve
       268β”‚ 
       269β”‚         try:
     β†’ 270β”‚             result = resolve_version(
       271β”‚                 self._package, self._provider, locked=locked, use_latest=use_latest
       272β”‚             )

   4  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/poetry/mixology/__init__.py:24 in resolve_version
        22β”‚     solver = VersionSolver(root, provider, locked=locked, use_latest=use_latest)
        23β”‚ 
     β†’  24β”‚     return solver.solve()
        25β”‚ 

   3  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/poetry/mixology/version_solver.py:82 in solve
        80β”‚             while next is not None:
        81β”‚                 self._propagate(next)
     β†’  82β”‚                 next = self._choose_package_version()
        83β”‚ 
        84β”‚             return self._result()

   2  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/poetry/mixology/version_solver.py:394 in _choose_package_version
       392β”‚             version = locked
       393β”‚ 
     β†’ 394β”‚         version = self._provider.complete_package(version)
       395β”‚ 
       396β”‚         conflict = False

   1  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/poetry/puzzle/provider.py:702 in complete_package
       700β”‚             clean_dependencies.append(dep)
       701β”‚ 
     β†’ 702β”‚         package.requires = clean_dependencies
       703β”‚ 
       704β”‚         return package

  AttributeError

  can't set attribute

  at /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/poetry/packages/dependency_package.py:38 in __setattr__
       34β”‚     def __setattr__(self, key: str, value: Any) -> None:
       35β”‚         if key in {"_dependency", "_package"}:
       36β”‚             return super().__setattr__(key, value)
       37β”‚ 
    β†’  38β”‚         setattr(self._package, key, value)
       39β”‚ 
       40β”‚     def __str__(self) -> str:
       41β”‚         return str(self._package)
       42β”‚ 

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
tardis10commented, Aug 2, 2021

Looks like 1.2.0a2 is out now and fixes this issue.

1reaction
onerandomusernamecommented, Aug 5, 2021

Looks like 1.2.0a2 is out now and fixes this issue.

Weird, it still happens for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: can't set attribute on v1.2.0a1 during lock or ...
I'm installing poetry using pip and suspect it's an issue with one of the dependencies. I will try to comb through my CI...
Read more >
Poetry add <package> returns AttributeError - Stack Overflow
Personally I would recommend looking into installing poetry with a tool like pipx or maybe another thing like that, the point is to...
Read more >
[Solved] AttributeError: can't set attribute in python - Finxter
The easiest way to fix the AttributeError:can't set attribute is to create a new namedtuple object with the namedtuple._replace() method. The result is...
Read more >
Python - What does property() do ? - Packet Coders
A property looks and acts like an ordinary attribute, except that you provide methods that ... line 1, in <module> AttributeError: can't set...
Read more >
Dependency Management With Python Poetry
Learn how Python Poetry will help you start new projects, maintain existing ones, and master dependency management.
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