Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run poetry under Python 2.7 (missing importlib_metadata) #1666

Closed
3 tasks done
schinckel opened this issue Dec 4, 2019 · 5 comments
Closed
3 tasks done
Labels
kind/bug Something isn't working as expected

Comments

@schinckel
Copy link

  • 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 Catalina
  • Poetry version: 0.12.17
  • Link of a Gist with the contents of your pyproject.toml file: N/A

Issue

I am in the process of transitioning to Python 3. As such, I am moving from Pipenv to Poetry.

I have poetry installed using pipx, which is being used to run things like poetry lock, and that all works great.

However, in my tox environment, I use poetry as a "dep", and the poetry install before running my tests.

In Python 2.7, this throws an exception:

[ImportError]
No module named importlib_metadata  

When I run it using -vv, I can see that the problem is not to do with installing the dependencies as such, but actually when poetry tries to parse the lock file:

Exception trace:
 /Users/matt/Development/ROSS/datamine/.tox/py27/lib/python2.7/site-packages/cleo/application.py in run() at line 94
   status_code = self.do_run(input_, output_)
 /Users/matt/Development/ROSS/datamine/.tox/py27/lib/python2.7/site-packages/poetry/console/application.py in do_run() at line 88
   return super(Application, self).do_run(i, o)
 /Users/matt/Development/ROSS/datamine/.tox/py27/lib/python2.7/site-packages/cleo/application.py in do_run() at line 197
   status_code = command.run(input_, output_)
 /Users/matt/Development/ROSS/datamine/.tox/py27/lib/python2.7/site-packages/poetry/console/commands/command.py in run() at line 77
   return super(BaseCommand, self).run(i, o)
 /Users/matt/Development/ROSS/datamine/.tox/py27/lib/python2.7/site-packages/cleo/commands/base_command.py in run() at line 136
   self.initialize(input_, output_)
 /Users/matt/Development/ROSS/datamine/.tox/py27/lib/python2.7/site-packages/poetry/console/commands/env_command.py in initialize() at line 18
   current_env = Env.get(self.poetry.file.parent)
 /Users/matt/Development/ROSS/datamine/.tox/py27/lib/python2.7/site-packages/poetry/console/commands/command.py in poetry() at line 62
   return self.get_application().poetry
 /Users/matt/Development/ROSS/datamine/.tox/py27/lib/python2.7/site-packages/poetry/console/application.py in poetry() at line 55
   from poetry.poetry import Poetry
 /Users/matt/Development/ROSS/datamine/.tox/py27/lib/python2.7/site-packages/poetry/poetry.py in <module>() at line 11
   from .json import validate_object
 /Users/matt/Development/ROSS/datamine/.tox/py27/lib/python2.7/site-packages/poetry/json/__init__.py in <module>() at line 4
   import jsonschema
 /Users/matt/Development/ROSS/datamine/.tox/py27/lib/python2.7/site-packages/jsonschema/__init__.py in <module>() at line 33
   import importlib_metadata as metadata

It seems that poetry does not install importlib_metadata when being installed under Python 2.7: adding it as a secondary dependency to my tox environment fixes this.

@schinckel schinckel added the kind/bug Something isn't working as expected label Dec 4, 2019
@schinckel
Copy link
Author

To be clear: I have a resolution - after some time I was able to see that I needed to have tox also install importlib_metadata, but this was non-obvious until running with poetry -vv, and I wonder if there is a way to have this install automatically as a dependency under Python 2.7?

@finswimmer
Copy link
Member

Hello @schinckel,

this (or something similar?) was reported before in #1487 and should be fixed by #1586

So please try it out with the latest preview release.

I will close this issue for now. But please leave a comment, if you still have any problems. I can reopen it any time.

fin swimmer

@schinckel
Copy link
Author

schinckel commented Dec 5, 2019 via email

@schinckel
Copy link
Author

I think maybe something else (prior to this change) fixed the issue: it appears to be working (but I've come across other issues related to running poetry from within tox that I am partway through documenting).

I've started a clean run without the extra requirement in my tox.ini on my CI server: I should know shortly if it has worked.

Copy link

github-actions bot commented Mar 3, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

2 participants