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
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
Any help is really appreciated. Please let me know if anymore information is needed.
@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.
@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
.
@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.
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
How can I install a specific version of Poetry when I am using recommended curl command:
likecurl -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.
@FelixKJose looks like your original issue is an upstream issue with virtualenv
, see https://github.com/pypa/virtualenv/issues/1873
@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.
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.
pip install -U virtualenv
works
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.
@zoopp Please try this steps.
If you installed virtualenv with a package manager something different than PIP (like brew,apt,yum, etc.)
@ycd Your suggestion fixes the issue in my case, thank you! I see I should have read the previous comments more carefully. :sweat_smile:
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:
A wonderful person to help me? ๐
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)
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.
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.
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.
For some reason, it was enough to just uninstall python3-virtualenv
using system package manager and the error disappeared (I'm on Ubuntu).
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
.
sudo apt remove --purge python3-virtualenv virtualenv
I can confirm that deleting virtualenv installed via apt on
Ubuntu 20.04.1 LTS
by doingsudo apt remove --purge python3-virtualenv virtualenv
and then installing virtualenv via pip by doingpip install -U virtualenv
results in thevirtualenv.seed.via_app_data
error disappearing andpoetry install
behaving normally.
@dash-samuel Saved my Day...Thanks man!
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!--
Most helpful comment
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 wassudo apt remove --purge python3-virtualenv virtualenv
, and then installvirtualenv
viapip3
.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 removetox
from theapt
installed packages list, and didsudo 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
andvirtualenv
(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 bypip3
installed ones.