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

poetry env use python3.7 gives error No module named 'virtualenv.seed.via_app_data' #2972

Closed
FelixKJose opened this issue Sep 25, 2020 · 34 comments
Labels
kind/bug Something isn't working as expected

Comments

@FelixKJose
Copy link

FelixKJose commented Sep 25, 2020

Hi,

I found issue on poetry 1.0.10 when I run poetry env use python3.7 as follows:

Traceback (most recent call last):
File "", line 1, in
NameError: name 'PosixPath' is not defined

So I tried to upgrade to poetry preview version by:

poetry self update --preview ∞
Updating to 1.1.0b4

  • Downloading poetry-1.1.0b4-darwin.tar.gz 100%

Then I tried to execute poetry env use python3.7, now I am getting a different error:

ModuleNotFoundError

No module named 'virtualenv.seed.via_app_data'

at :973 in _find_and_load_unlocked

  • OS version and name: MacOS Mojave
  • Poetry version: 1.1.0b4

Any help is really appreciated. Please let me know if anymore information is needed.

@FelixKJose FelixKJose added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Sep 25, 2020
@mbelang
Copy link

mbelang commented Sep 25, 2020

@FelixKJose I didn't manage to repro locally with 1.0.10. I do had that error on circleci with circleci:python-3.7.6 docker image as executor.

I've upgraded to python-3.7.9 executor and I have a different problem now. Poetry is stuck is loop installing some dependencies.

@abn
Copy link
Member

abn commented Sep 25, 2020

@FelixKJose can you run that with -vvv and provide the stack trace please?

@mbelang the loop could when the project was locked using 1.1 and you are attempting to install the project using 1.0.

@mbelang
Copy link

mbelang commented Sep 25, 2020

@abn Thanks for the answer. The error reported by @FelixKJose I got it with python 3.7.6

I was not able to reproduce with python 3.7.7 nor 3.7.8

I do have an other error with python 3.7.9

Looking in indexes: https://pypi.org/simple, https://pypi.fury.io/********************/********/
Collecting sqlalchemy==1.3.15
  Downloading SQLAlchemy-1.3.15.tar.gz (6.1 MB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: /home/circleci/.cache/pypoetry/virtualenvs/coredata-3aSsmiER-py3.7/bin/python /home/circleci/.cache/pypoetry/virtualenvs/coredata-3aSsmiER-py3.7/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-g0aixbk8/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://pypi.fury.io/********************/********/ -- 'setuptools>=40.8.0' wheel
       cwd: None
  Complete output (44 lines):
  Traceback (most recent call last):
    File "/home/circleci/.pyenv/versions/3.7.9/lib/python3.7/runpy.py", line 193, in _run_module_as_main
      "__main__", mod_spec)
    File "/home/circleci/.pyenv/versions/3.7.9/lib/python3.7/runpy.py", line 85, in _run_code
      exec(code, run_globals)
    File "/home/circleci/.cache/pypoetry/virtualenvs/coredata-3aSsmiER-py3.7/lib/python3.7/site-packages/pip/__main__.py", line 26, in <module>
      sys.exit(_main())
    File "/home/circleci/.cache/pypoetry/virtualenvs/coredata-3aSsmiER-py3.7/lib/python3.7/site-packages/pip/_internal/cli/main.py", line 73, in main
      command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
    File "/home/circleci/.cache/pypoetry/virtualenvs/coredata-3aSsmiER-py3.7/lib/python3.7/site-packages/pip/_internal/commands/__init__.py", line 104, in create_command
      module = importlib.import_module(module_path)
    File "/home/circleci/.pyenv/versions/3.7.9/lib/python3.7/importlib/__init__.py", line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
    File "<frozen importlib._bootstrap>", line 983, in _find_and_load
    File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
    File "<frozen importlib._bootstrap_external>", line 728, in exec_module
    File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
    File "/home/circleci/.cache/pypoetry/virtualenvs/coredata-3aSsmiER-py3.7/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 24, in <module>
      from pip._internal.cli.req_command import RequirementCommand, with_cleanup
    File "/home/circleci/.cache/pypoetry/virtualenvs/coredata-3aSsmiER-py3.7/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 16, in <module>
      from pip._internal.index.package_finder import PackageFinder
    File "/home/circleci/.cache/pypoetry/virtualenvs/coredata-3aSsmiER-py3.7/lib/python3.7/site-packages/pip/_internal/index/package_finder.py", line 21, in <module>
      from pip._internal.index.collector import parse_links
    File "/home/circleci/.cache/pypoetry/virtualenvs/coredata-3aSsmiER-py3.7/lib/python3.7/site-packages/pip/_internal/index/collector.py", line 14, in <module>
      from pip._vendor import html5lib, requests
    File "/home/circleci/.cache/pypoetry/virtualenvs/coredata-3aSsmiER-py3.7/lib/python3.7/site-packages/pip/_vendor/requests/__init__.py", line 114, in <module>
      from . import utils
    File "/home/circleci/.cache/pypoetry/virtualenvs/coredata-3aSsmiER-py3.7/lib/python3.7/site-packages/pip/_vendor/requests/utils.py", line 25, in <module>
      from . import certs
    File "/home/circleci/.cache/pypoetry/virtualenvs/coredata-3aSsmiER-py3.7/lib/python3.7/site-packages/pip/_vendor/requests/certs.py", line 15, in <module>
      from pip._vendor.certifi import where
    File "/home/circleci/.cache/pypoetry/virtualenvs/coredata-3aSsmiER-py3.7/lib/python3.7/site-packages/pip/_vendor/certifi/__init__.py", line 1, in <module>
      from .core import contents, where
    File "/home/circleci/.cache/pypoetry/virtualenvs/coredata-3aSsmiER-py3.7/lib/python3.7/site-packages/pip/_vendor/certifi/core.py", line 12, in <module>
      from importlib.resources import read_text
    File "/home/circleci/.pyenv/versions/3.7.9/lib/python3.7/importlib/resources.py", line 11, in <module>
      from typing import Iterable, Iterator, Optional, Set, Union   # noqa: F401
    File "/home/circleci/.cache/pypoetry/virtualenvs/coredata-3aSsmiER-py3.7/lib/python3.7/site-packages/typing.py", line 1357, in <module>
      class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
    File "/home/circleci/.cache/pypoetry/virtualenvs/coredata-3aSsmiER-py3.7/lib/python3.7/site-packages/typing.py", line 1005, in __new__
      self._abc_registry = extra._abc_registry
  AttributeError: type object 'Callable' has no attribute '_abc_registry'
  ----------------------------------------
ERROR: Command errored out with exit status 1: /home/circleci/.cache/pypoetry/virtualenvs/coredata-3aSsmiER-py3.7/bin/python /home/circleci/.cache/pypoetry/virtualenvs/coredata-3aSsmiER-py3.7/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-g0aixbk8/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://pypi.fury.io/********************/********/ -- 'setuptools>=40.8.0' wheel Check the logs for full command output.

@FelixKJose
Copy link
Author

FelixKJose commented Sep 27, 2020

Hello @abn @mbelang
The issue I have reported is resolved when I use '1.1.0rc1'

Thank you for the replies.

But I have one question:
How can I install a specific version of Poetry when I am using recommended curl command:
like curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3.7

poetry -V

Python 2.7 will no longer be supported in the next feature release of Poetry (1.2).
You should consider updating your Python version to a supported one.

Note that you will still be able to manage Python 2.7 projects by using the env command.
See https://python-poetry.org/docs/managing-environments/ for more information.

Poetry version 1.1.0rc1

But:

python3.7 get-poetry.py --version 0.12.0
/Library/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'get-poetry.py': [Errno 2] No such file or directory

@abn
Copy link
Member

abn commented Sep 27, 2020

How can I install a specific version of Poetry when I am using recommended curl command:
like curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3.7

curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3.7 - --help

Note the - in between python3.7 and --help.

python3.7 get-poetry.py --version 0.12.0
/Library/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'get-poetry.py': [Errno 2] No such file or directory

This is because the curl command above does nto save the script. You can do the following (note the -O option).

curl -sSLO https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py
python3.7 get-poetry.py --help

Also for general queries, I would also recommend drobbing by our Discord Server. You might get quicker responses. :)

@mbelang hmm interesting; I will take a look when I get some time. Thank you for the stack trace.

@abn
Copy link
Member

abn commented Sep 27, 2020

@FelixKJose looks like your original issue is an upstream issue with virtualenv, see pypa/virtualenv#1873

@abn
Copy link
Member

abn commented Sep 27, 2020

@mbelang looks like the trace indicates the issue is with pip tryig to setup the PEP 517 build environment. Maybe invalidate the cache so poetry recreates the environment.

@ycd
Copy link

ycd commented Sep 28, 2020

Like @abn mentioned(In that issue you can see my comment from Jul 15) it's a problem with virtualenv more specifically if you have two virtualenv installed (In my case i installed one with APT, and one with PIP) that's causing the error.

@gabrielclimb
Copy link

pip install -U virtualenv works

@zoopp
Copy link

zoopp commented Oct 7, 2020

I experience this issue with Python 3.8.5 as well (when running poetry install). I'll attach the stack trace in case it's relevant:

 Stack trace:

  23  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/console_application.py:131 in run
       129│             parsed_args = resolved_command.args
       130│ 
     → 131│             status_code = command.handle(parsed_args, io)
       132│         except KeyboardInterrupt:
       133│             status_code = 1

  22  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/api/command/command.py:120 in handle
       118│     def handle(self, args, io):  # type: (Args, IO) -> int
       119│         try:
     → 120│             status_code = self._do_handle(args, io)
       121│         except KeyboardInterrupt:
       122│             if io.is_debug():

  21  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/api/command/command.py:163 in _do_handle
       161│         if self._dispatcher and self._dispatcher.has_listeners(PRE_HANDLE):
       162│             event = PreHandleEvent(args, io, self)
     → 163│             self._dispatcher.dispatch(PRE_HANDLE, event)
       164│ 
       165│             if event.is_handled():

  20  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/api/event/event_dispatcher.py:22 in dispatch
        20│ 
        21│         if listeners:
     →  22│             self._do_dispatch(listeners, event_name, event)
        23│ 
        24│         return event

  19  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/api/event/event_dispatcher.py:89 in _do_dispatch
        87│                 break
        88│ 
     →  89│             listener(event, event_name, self)
        90│ 
        91│     def _sort_listeners(self, event_name):  # type: (str) -> None

  18  ~/.poetry/lib/poetry/console/config/application_config.py:119 in set_env
       117│ 
       118│         env_manager = EnvManager(poetry)
     → 119│         env = env_manager.create_venv(io)
       120│ 
       121│         if env.is_venv() and io.is_verbose():

  17  ~/.poetry/lib/poetry/utils/env.py:645 in create_venv
        643│             )
        644│ 
     →  645│             self.build_venv(venv, executable=executable)
        646│         else:
        647│             if force:

  16  ~/.poetry/lib/poetry/utils/env.py:686 in build_venv
        684│         if isinstance(executable, Path):
        685│             executable = executable.resolve().as_posix()
     →  686│         return virtualenv.cli_run(
        687│             [
        688│                 "--no-download",

  15  ~/.poetry/lib/poetry/_vendor/py3.8/virtualenv/run/__init__.py:26 in cli_run
        24│     :return: the session object of the creation (its structure for now is experimental and might change on short notice)
        25│     """
     →  26│     of_session = session_via_cli(args, options, setup_logging)
        27│     with of_session:
        28│         of_session.run()

  14  ~/.poetry/lib/poetry/_vendor/py3.8/virtualenv/run/__init__.py:42 in session_via_cli
        40│     :return: the session object of the creation (its structure for now is experimental and might change on short notice)
        41│     """
     →  42│     parser, elements = build_parser(args, options, setup_logging)
        43│     options = parser.parse_args(args)
        44│     creator, seeder, activators = tuple(e.create(options) for e in elements)  # create types

  13  ~/.poetry/lib/poetry/_vendor/py3.8/virtualenv/run/__init__.py:69 in build_parser
        67│     elements = [
        68│         CreatorSelector(interpreter, parser),
     →  69│         SeederSelector(interpreter, parser),
        70│         ActivationSelector(interpreter, parser),
        71│     ]

  12  ~/.poetry/lib/poetry/_vendor/py3.8/virtualenv/run/plugin/seeders.py:8 in __init__
        6│ class SeederSelector(ComponentBuilder):
        7│     def __init__(self, interpreter, parser):
     →  8│         possible = self.options("virtualenv.seed")
        9│         super(SeederSelector, self).__init__(interpreter, parser, "seeder", possible)
       10│ 

  11  ~/.poetry/lib/poetry/_vendor/py3.8/virtualenv/run/plugin/base.py:39 in options
       37│     def options(cls, key):
       38│         if cls._OPTIONS is None:
     → 39│             cls._OPTIONS = cls.entry_points_for(key)
       40│         return cls._OPTIONS
       41│ 

  10  ~/.poetry/lib/poetry/_vendor/py3.8/virtualenv/run/plugin/base.py:18 in entry_points_for
       16│     @classmethod
       17│     def entry_points_for(cls, key):
     → 18│         return OrderedDict((e.name, e.load()) for e in cls.entry_points().get(key, {}))
       19│ 
       20│     @staticmethod

   9  ~/.poetry/lib/poetry/_vendor/py3.8/virtualenv/run/plugin/base.py:18 in <genexpr>
       16│     @classmethod
       17│     def entry_points_for(cls, key):
     → 18│         return OrderedDict((e.name, e.load()) for e in cls.entry_points().get(key, {}))
       19│ 
       20│     @staticmethod

   8  /usr/lib/python3.8/importlib/metadata.py:77 in load
        75│         """
        76│         match = self.pattern.match(self.value)
     →  77│         module = import_module(match.group('module'))
        78│         attrs = filter(None, (match.group('attr') or '').split('.'))
        79│         return functools.reduce(getattr, attrs, module)

   7  /usr/lib/python3.8/importlib/__init__.py:127 in import_module
       125│                 break
       126│             level += 1
     → 127│     return _bootstrap._gcd_import(name[level:], package, level)
       128│ 
       129│ 

   6  <frozen importlib._bootstrap>:1014 in _gcd_import

   5  <frozen importlib._bootstrap>:991 in _find_and_load

   4  <frozen importlib._bootstrap>:961 in _find_and_load_unlocked

   3  <frozen importlib._bootstrap>:219 in _call_with_frames_removed

   2  <frozen importlib._bootstrap>:1014 in _gcd_import

   1  <frozen importlib._bootstrap>:991 in _find_and_load

  ModuleNotFoundError

  No module named 'virtualenv.seed.via_app_data'

  at <frozen importlib._bootstrap>:973 in _find_and_load_unlocked

I've been iterating stable release versions backwards starting from v1.1.2 and the latest one in which this doesn't happen is 1.0.10.

@ycd
Copy link

ycd commented Oct 7, 2020

@zoopp Please try this steps.

If you installed virtualenv with a package manager something different than PIP (like brew,apt,yum, etc.)

  • Find it and delete it
  • You can locate it via which virtualenv
  • If you are unable to delete it, try installing your current version from pip

@zoopp
Copy link

zoopp commented Oct 7, 2020

@ycd Your suggestion fixes the issue in my case, thank you! I see I should have read the previous comments more carefully. 😅

@demangejeremy
Copy link

demangejeremy commented Oct 20, 2020

Error that cannot be resolved despite your answers. This is what I have (when running poetry install):

  ModuleNotFoundError

  No module named 'virtualenv.seed.via_app_data'

  at <frozen importlib._bootstrap>:965 in _find_and_load_unlocked

Other informations:

  • Poetry (version 1.1.3)
  • macOS Catalina (version 10.15.7)
  • Anaconda (Python 3.7.4)

A wonderful person to help me? 🙏

@nicolashainaux
Copy link

Exactly same problem here. @ycd suggestions followed and unfortunately did not help.
Poetry version 1.1.4
OS is Ubuntu 20.04 (Build worker image on AppVeyor) with package python-is-python3 (to avoid having poetry start with python2)
System python (3.8) used (other python environments installed via pyenv and should be harmless: 3.6.12, 3.7.9)

@nicolashainaux
Copy link

Well no, I finally found out: when installing via pip after having deleted /usr/local/bin/virtualenv, it just kept using the wrong libraries. What I had to do was sudo apt remove --purge python3-virtualenv virtualenv, and then install virtualenv via pip3.

I did not actually installed these packages myself, they were installed as dependencies of tox and nothing else. So actually what I did was to remove tox from the apt installed packages list, and did sudo pip3 install tox tox-pyenv.

So, @demangejeremy I don't know how it is with your MacOS / Anaconda platform, but it would be an incredible coincidence to get exactly the same problem at the same time but from a totally different cause. I'd suggest you to not give up and hunt for packages like python3-virtualenv and virtualenv (maybe the names on MacOS differ from the ones on Ubuntu) that would have been installed by your package manager (maybe as dependencies), remove them and replace them by pip3 installed ones.

@Ayuei
Copy link

Ayuei commented Oct 30, 2020

I'm on an arch-based system, I had to do the opposite of what was suggested above.

For me, I had to install python-poetry and python-virtualenv through pacman and uninstall the poetry I installed via the shell script and/or pip.

@dash-samuel
Copy link

dash-samuel commented Nov 25, 2020

sudo apt remove --purge python3-virtualenv virtualenv

I can confirm that deleting virtualenv installed via apt on Ubuntu 20.04.1 LTS by doing sudo apt remove --purge python3-virtualenv virtualenv and then installing virtualenv via pip by doing pip install -U virtualenv results in the virtualenv.seed.via_app_data error disappearing and poetry install behaving normally.

@and-semakin
Copy link

For some reason, it was enough to just uninstall python3-virtualenv using system package manager and the error disappeared (I'm on Ubuntu).

@tomzx
Copy link
Contributor

tomzx commented Nov 26, 2020

I've seen this error on CircleCI using circleci/python:3.8.2-buster but it went away by using circleci/python:3.8.6-buster.

@KANE-99
Copy link

KANE-99 commented Dec 4, 2020

sudo apt remove --purge python3-virtualenv virtualenv

I can confirm that deleting virtualenv installed via apt on Ubuntu 20.04.1 LTS by doing sudo apt remove --purge python3-virtualenv virtualenv and then installing virtualenv via pip by doing pip install -U virtualenv results in the virtualenv.seed.via_app_data error disappearing and poetry install behaving normally.

@dash-samuel Saved my Day...Thanks man!

@benkehoe
Copy link

I was experiencing this with 3.6 in pyenv, on Ubuntu 18.04 in WSL, and upgrading virtualenv worked for me.

$ pyenv local 3.6.10
$ poetry env use $(which python)
  ModuleNotFoundError

  No module named 'virtualenv.seed.via_app_data'

  at <frozen importlib._bootstrap>:953 in _find_and_load_unlocked

$ python -m pip install -U virtualenv
$ python -m virtualenv --version
virtualenv 20.0.21 from ~/.local/lib/python3.6/site-packages/virtualenv/__init__.py
$ python -m pip install -U virtualenv
Successfully installed virtualenv-20.2.2
$ poetry env use $(pyenv which python)
--success!--

@jedie
Copy link

jedie commented Jan 8, 2021

i ran also in the problem and confirm that #2972 (comment) is the solution...

@joeledwards
Copy link

After following the accepted recommendation from above, I am still running into this error.

  • Ubuntu 20.04.1 LTS
  • pyenv 1.2.18
  • Python 3.7.7
  • virtualenv 20.0.21
  • poetry 1.1.4
  • pip 20.1.1

I am attempting to run install in a newly created project.

poetry install -vvv
Creating virtualenv aws-sso-zyhrJX5_-py3.7 in /home/joel/.cache/pypoetry/virtualenvs

  Stack trace:

  23  ~/.poetry/lib/poetry/_vendor/py3.7/clikit/console_application.py:131 in run
       129│             parsed_args = resolved_command.args
       130│ 
     → 131│             status_code = command.handle(parsed_args, io)
       132│         except KeyboardInterrupt:
       133│             status_code = 1

  22  ~/.poetry/lib/poetry/_vendor/py3.7/clikit/api/command/command.py:120 in handle
       118│     def handle(self, args, io):  # type: (Args, IO) -> int
       119│         try:
     → 120│             status_code = self._do_handle(args, io)
       121│         except KeyboardInterrupt:
       122│             if io.is_debug():

  21  ~/.poetry/lib/poetry/_vendor/py3.7/clikit/api/command/command.py:163 in _do_handle
       161│         if self._dispatcher and self._dispatcher.has_listeners(PRE_HANDLE):
       162│             event = PreHandleEvent(args, io, self)
     → 163│             self._dispatcher.dispatch(PRE_HANDLE, event)
       164│ 
       165│             if event.is_handled():

  20  ~/.poetry/lib/poetry/_vendor/py3.7/clikit/api/event/event_dispatcher.py:22 in dispatch
        20│ 
        21│         if listeners:
     →  22│             self._do_dispatch(listeners, event_name, event)
        23│ 
        24│         return event

  19  ~/.poetry/lib/poetry/_vendor/py3.7/clikit/api/event/event_dispatcher.py:89 in _do_dispatch
        87│                 break
        88│ 
     →  89│             listener(event, event_name, self)
        90│ 
        91│     def _sort_listeners(self, event_name):  # type: (str) -> None

  18  ~/.poetry/lib/poetry/console/config/application_config.py:119 in set_env
       117│ 
       118│         env_manager = EnvManager(poetry)
     → 119│         env = env_manager.create_venv(io)
       120│ 
       121│         if env.is_venv() and io.is_verbose():

  17  ~/.poetry/lib/poetry/utils/env.py:761 in create_venv
        759│             )
        760│ 
     →  761│             self.build_venv(venv, executable=executable)
        762│         else:
        763│             if force:

  16  ~/.poetry/lib/poetry/utils/env.py:808 in build_venv
        806│                 "--python",
        807│                 executable or sys.executable,
     →  808│                 str(path),
        809│             ]
        810│         )

  15  ~/.poetry/lib/poetry/_vendor/py3.7/virtualenv/run/__init__.py:26 in cli_run
        24│     :return: the session object of the creation (its structure for now is experimental and might change on short notice)
        25│     """
     →  26│     of_session = session_via_cli(args, options, setup_logging)
        27│     with of_session:
        28│         of_session.run()

  14  ~/.poetry/lib/poetry/_vendor/py3.7/virtualenv/run/__init__.py:42 in session_via_cli
        40│     :return: the session object of the creation (its structure for now is experimental and might change on short notice)
        41│     """
     →  42│     parser, elements = build_parser(args, options, setup_logging)
        43│     options = parser.parse_args(args)
        44│     creator, seeder, activators = tuple(e.create(options) for e in elements)  # create types

  13  ~/.poetry/lib/poetry/_vendor/py3.7/virtualenv/run/__init__.py:69 in build_parser
        67│     elements = [
        68│         CreatorSelector(interpreter, parser),
     →  69│         SeederSelector(interpreter, parser),
        70│         ActivationSelector(interpreter, parser),
        71│     ]

  12  ~/.poetry/lib/poetry/_vendor/py3.7/virtualenv/run/plugin/seeders.py:8 in __init__
        6│ class SeederSelector(ComponentBuilder):
        7│     def __init__(self, interpreter, parser):
     →  8│         possible = self.options("virtualenv.seed")
        9│         super(SeederSelector, self).__init__(interpreter, parser, "seeder", possible)
       10│ 

  11  ~/.poetry/lib/poetry/_vendor/py3.7/virtualenv/run/plugin/base.py:39 in options
       37│     def options(cls, key):
       38│         if cls._OPTIONS is None:
     → 39│             cls._OPTIONS = cls.entry_points_for(key)
       40│         return cls._OPTIONS
       41│ 

  10  ~/.poetry/lib/poetry/_vendor/py3.7/virtualenv/run/plugin/base.py:18 in entry_points_for
       16│     @classmethod
       17│     def entry_points_for(cls, key):
     → 18│         return OrderedDict((e.name, e.load()) for e in cls.entry_points().get(key, {}))
       19│ 
       20│     @staticmethod

   9  ~/.poetry/lib/poetry/_vendor/py3.7/virtualenv/run/plugin/base.py:18 in <genexpr>
       16│     @classmethod
       17│     def entry_points_for(cls, key):
     → 18│         return OrderedDict((e.name, e.load()) for e in cls.entry_points().get(key, {}))
       19│ 
       20│     @staticmethod

   8  ~/.poetry/lib/poetry/_vendor/py3.7/importlib_metadata/__init__.py:105 in load
       103│         """
       104│         match = self.pattern.match(self.value)
     → 105│         module = import_module(match.group('module'))
       106│         attrs = filter(None, (match.group('attr') or '').split('.'))
       107│         return functools.reduce(getattr, attrs, module)

   7  ~/.pyenv/versions/3.7.7/lib/python3.7/importlib/__init__.py:127 in import_module
       125│                 break
       126│             level += 1
     → 127│     return _bootstrap._gcd_import(name[level:], package, level)
       128│ 
       129│ 

   6  <frozen importlib._bootstrap>:1006 in _gcd_import

   5  <frozen importlib._bootstrap>:983 in _find_and_load

   4  <frozen importlib._bootstrap>:953 in _find_and_load_unlocked

   3  <frozen importlib._bootstrap>:219 in _call_with_frames_removed

   2  <frozen importlib._bootstrap>:1006 in _gcd_import

   1  <frozen importlib._bootstrap>:983 in _find_and_load

  ModuleNotFoundError

  No module named 'virtualenv.seed.via_app_data'

  at <frozen importlib._bootstrap>:965 in _find_and_load_unlocked

@joeledwards
Copy link

I didn't have a global version of virtualenv installed. However, a fresh install of it worked:
pip install --force-reinstall virtualenv

@alexb7217
Copy link

I also had this issue, or a variant of it.

Installed poetry

Used poetry lockfor one app and everything worked fine

Used poetry lock for a second app and received the following error message:

$ poetry lock      
Creating virtualenv mytestapp-vm7OCEgV-py3.8 in /home/alexb7217/.cache/pypoetry/virtualenvs

  ModuleNotFoundError

  No module named 'virtualenv.seed.via_app_data'

  at <frozen importlib._bootstrap>:973 in _find_and_load_unlocked

Followed the most simple suggestion:

$ sudo apt remove --purge python3-virtualenv

Re-ran poetry-lock

$ poetry lock  
Updating dependenciesResolving dependencies... (1.1s)

Everything works great, that's it! ::thumbsup::

OS: Ubuntu 20.04.1 LTS x86_64

@umarhussain88
Copy link

had the same issue on ubuntu 20.04 LTS via wsl2, I also have a few package managers that I use so I wondered if that caused an issue, but I had the same issue in docker.

$ sudo apt remove --purge python3-virtualenv did the trick, cheers my man!

@rjaduthie
Copy link

rjaduthie commented Apr 19, 2021

For the record, if it helps someone else, I had this same issue. The situation was complicated by my use ofpyenv. If trying the command:
/Users/my_user/.poetry/bin/poetry env use /Users/my_user/.pyenv/versions/3.8.2/bin/python
... then I would get:

ModuleNotFoundError

  No module named 'virtualenv.seed.via_app_data'

  at <frozen importlib._bootstrap>:948 in _find_and_load_unlocked

I tried a lot of stuff - installing and re-installing the virtualenv, for example. No joy.

Using the -vvv option shed some light on the situation; the command being like:
/Users/my_user/.poetry/bin/poetry env use -vvv /Users/my_user/.pyenv/versions/3.8.2/bin/python

It seems that Poetry was using Python 3.6. The solution was to activate Python 3.6 via pyenv and then uninstalling the virtualenv package with the appropriate pip.

@AlexandreDecan
Copy link

I see that poetry vendors its dependencies and use these vendored dependencies when poetry CLI is used (at least when using the get-poetry.py script). So why do we have this issue that seems related to the virtualenv not vendored by poetry? I'm missing something.

@abn
Copy link
Member

abn commented Apr 23, 2021

Depends on how poetry was installed and also the version poetry. And additionally, it could also be because of how the debian packages override site paths. Poetry's vendoring works by injecting the vendor site into the path. But without specifics about the environment it is hard to determine why exactly this might be happening.

As for the issue itself, since the creation of this issue a few things have happened. This includes poetry no longer vendoring dependencies and deprecating get-poetry.py script in favour of install-poetry.py.

I am closing this issue as the root issue should no longer happen, unless the issue is a distribution issue (eg: ubuntu/virtualenv, ubuntu/distutils etc.).

@FabricioPatrocinio
Copy link

@nicolashainaux Thanks, this definitely solved my problem.

@Ecno92
Copy link

Ecno92 commented May 16, 2021

@abn, I am also affected by the issue. So I tried a few things based on your suggestions in a Docker container.
Below you can find the Dockerfile that I used including the 2 installation steps and the results.

FROM ubuntu:focal
RUN apt update && apt install -y python3-virtualenv curl

# OPTION 1:
# Succeeds installing, however user faces the 'No module named 'virtualenv.seed.via_app_data'
# when using 'poetry new ...'  and 'poetry shell' when trying to use poetry in the derived container.
# RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3

# OPTION 2:
# Fails to install with the 'No module named 'virtualenv.seed.via_app_data' error
# RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python3
RUN echo "source $HOME/.poetry/env" >> /root/.bashrc

I did not do further checking on the internals (yet), but as I think we can conclude that Poetry and the install-poetry.py script are incompatible with python3-virtualenv of ubuntu:focal.
Based on the comments above I can see that a newer version of virtualenv on the system resolves the issue.
I consider removing the system package and replacing it by a pip installed (newer) version a workaround and not a solution.
In some cases it is just not possible to require users to remove the system package as other packages may have a dependency on it, or the system administrator may not provide root access to the user.

As the issue is closed I would like to hear if you share my opinion that the issue is still present. If so, then we can look into finding a solution. :)

@abn abn removed the status/triage This issue needs to be triaged label Mar 3, 2022
@joeflack4
Copy link

My pip was defaulting to 3.7, so when I installed Poetry, it was not good. My python3 was 3.9, so I did python3 -m pip install poetry. Then poetry install worked.

@karzmei
Copy link

karzmei commented Nov 8, 2022

This worked for me as well, but needed a reboot (or at least re-openning the terminal) after these commands.

sudo apt remove --purge python3-virtualenv virtualenv

I can confirm that deleting virtualenv installed via apt on Ubuntu 20.04.1 LTS by doing sudo apt remove --purge python3-virtualenv virtualenv and then installing virtualenv via pip by doing pip install -U virtualenv results in the virtualenv.seed.via_app_data error disappearing and poetry install behaving normally.

Copy link

github-actions bot commented Mar 1, 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 1, 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