Python restricted dependencies for multiple Python versions fail: 'Array' object has no attribute 'strip'
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 (
-vvvoption). -
OS version and name: Ubuntu 18.10
-
Poetry version: Poetry 0.12.11 (bug does also affect 0.12.10)
-
Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/okin/9fca594f2a4ba9917f1c292752d21e4c
Issue
I want to configure an dependency that is only applied when specific Python versions are used.
The documentation shows an example that matches my case: pathlib2 = { version = "^2.2", python = ["~2.7", "^3.2"] }
I added this to my project config.
Whenever I now try to run poetry install, poetry update or poetry check I am greeted with the following message:
[AttributeError]
'Array' object has no attribute 'strip'
No further action is done as poetry appears to break in this case.
Debug output from poetry check
[AttributeError]
'Array' object has no attribute 'strip'
Exception trace:
/home/wenselowski/.poetry/lib/poetry/_vendor/py3.6/cleo/application.py in run() at line 94
status_code = self.do_run(input_, output_)
/home/wenselowski/.poetry/lib/poetry/console/application.py in do_run() at line 88
return super(Application, self).do_run(i, o)
/home/wenselowski/.poetry/lib/poetry/_vendor/py3.6/cleo/application.py in do_run() at line 197
status_code = command.run(input_, output_)
/home/wenselowski/.poetry/lib/poetry/console/commands/command.py in run() at line 77
return super(BaseCommand, self).run(i, o)
/home/wenselowski/.poetry/lib/poetry/_vendor/py3.6/cleo/commands/base_command.py in run() at line 146
status_code = self.execute(input_, output_)
/home/wenselowski/.poetry/lib/poetry/_vendor/py3.6/cleo/commands/command.py in execute() at line 107
return self.handle()
/home/wenselowski/.poetry/lib/poetry/console/commands/check.py in handle() at line 13
check_result = self.poetry.check(self.poetry.local_config, strict=True)
/home/wenselowski/.poetry/lib/poetry/console/commands/command.py in poetry() at line 62
return self.get_application().poetry
/home/wenselowski/.poetry/lib/poetry/console/application.py in poetry() at line 60
self._poetry = Poetry.create(os.getcwd())
/home/wenselowski/.poetry/lib/poetry/poetry.py in create() at line 148
package.add_dependency(name, constraint)
/home/wenselowski/.poetry/lib/poetry/packages/package.py in add_dependency() at line 304
dependency.python_versions = python_versions
/home/wenselowski/.poetry/lib/poetry/packages/dependency.py in python_versions() at line 89
self._python_constraint = parse_constraint(value)
/home/wenselowski/.poetry/lib/poetry/semver/__init__.py in parse_constraint() at line 19
or_constraints = re.split(r"\s*\|\|?\s*", constraints.strip())
check
Workaround
No error is shown when configuring it as multiple requirements but no further testing was done if this actually would resolve correctly.
pathlib2 = [
{ version = "^2.2", python = "~2.7" },
{ version = "^2.2", python = "^3.2" }
]
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (1 by maintainers)

Top Related StackOverflow Question
Hi @stephsamson , I was in your tutorial at Pycon.de 😃
Regarding the fix, I chose not to support an older Python version in my project so I have no need for the double pipe any more. However, it is good that you put it in the docs. It was definitely missing there.
Thanks for your time.
@webartifex does using the double pipe fix your issue?