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

ModuleNotFoundError: No module named 'poetry' #4218

Closed
Systemcluster opened this issue Apr 29, 2020 · 5 comments
Closed

ModuleNotFoundError: No module named 'poetry' #4218

Systemcluster opened this issue Apr 29, 2020 · 5 comments
Labels
Type: Bug 🐛 This issue is a bug.

Comments

@Systemcluster
Copy link

Issue description

When installing a dependency that's built using poetry (e.g. flake8-annotations) using Pipenv 2020.4.1b1, pipenv install or pipenv update fail with the error ModuleNotFoundError: No module named 'poetry'.

Steps to replicate

Assume an environment with Python 3.8 and Pipenv 2020.4.1b1.

Create a Pipfile with the following content:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
flake8 = ">=3.7"
flake8-annotations = ">=2.0"

[packages]

[requires]
python_version = "3.8"

Run pipenv install. The resolver will fail with the above mentioned error message.

(Whether poetry is installed or not does not change this.)

Output of pipenv install --verbose

Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Building requirements...
Resolving dependencies...

                          ROUND 1
Current constraints:
  flake8>=3.7 (from -r C:\Users\Chris\AppData\Local\Temp\pipenvgpsd96rurequirements\pipenv-8xkbw7k7-constraints.txt (line 3))
  flake8-annotations>=2.0 (from -r C:\Users\Chris\AppData\Local\Temp\pipenvgpsd96rurequirements\pipenv-8xkbw7k7-constraints.txt (line 2))

Finding the best candidates:
FAIL
  found candidate flake8==3.7.9 (constraint was >=3.7)
  found candidate flake8-annotations==2.1.0 (constraint was >=2.0)

Finding secondary dependencies:
  flake8==3.7.9             requires entrypoints<0.4.0,>=0.3.0, mccabe<0.7.0,>=0.6.0, pycodestyle<2.6.0,>=2.5.0, pyflakes<2.2.0,>=2.1.0
  flake8-annotations==2.1.0 not in cache, need to check index
Traceback (most recent call last):
  File "c:/users/chris/appdata/local/programs/python/python38/lib/site-packages/pipenv/resolver.py", line 807, in <module>
    main()
  File "c:/users/chris/appdata/local/programs/python/python38/lib/site-packages/pipenv/resolver.py", line 802, in main
    _main(parsed.pre, parsed.clear, parsed.verbose, parsed.system, parsed.write,
  File "c:/users/chris/appdata/local/programs/python/python38/lib/site-packages/pipenv/resolver.py", line 785, in _main
    resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages)
  File "c:/users/chris/appdata/local/programs/python/python38/lib/site-packages/pipenv/resolver.py", line 746, in resolve_packages
    results, resolver = resolve(
  File "c:/users/chris/appdata/local/programs/python/python38/lib/site-packages/pipenv/resolver.py", line 728, in resolve
    return resolve_deps(
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\utils.py", line 1371, in resolve_deps
    results, hashes, markers_lookup, resolver, skipped = actually_resolve_deps(
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\utils.py", line 1086, in actually_resolve_deps
    resolver.resolve()
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\utils.py", line 807, in resolve
    results = self.resolver.resolve(max_rounds=environments.PIPENV_MAX_ROUNDS)
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\piptools\resolver.py", line 180, in resolve
    has_changed, best_matches = self._resolve_one_round()
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\piptools\resolver.py", line 268, in _resolve_one_round
    their_constraints.extend(self._iter_dependencies(best_match))
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\piptools\resolver.py", line 383, in _iter_dependencies
    dependencies = self.repository.get_dependencies(ireq)
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\piptools\repositories\pypi.py", line 226, in get_dependencies
    legacy_results = self.get_legacy_dependencies(ireq)
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\piptools\repositories\pypi.py", line 347, in get_legacy_dependencies
    results, ireq = self.resolve_reqs(
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\piptools\repositories\pypi.py", line 303, in resolve_reqs
    results = resolver._resolve_one(reqset, ireq)
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_internal\legacy_resolve.py", line 339, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_internal\legacy_resolve.py", line 287, in _get_abstract_dist_for
    abstract_dist = self.preparer.prepare_linked_requirement(req)
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_internal\operations\prepare.py", line 508, in prepare_linked_requirement
    abstract_dist = _get_prepared_distribution(
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_internal\operations\prepare.py", line 95, in _get_prepared_distribution
    abstract_dist.prepare_distribution_metadata(finder, build_isolation)
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_internal\distributions\sdist.py", line 40, in prepare_distribution_metadata
    self.req.prepare_metadata()
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_internal\req\req_install.py", line 564, in prepare_metadata
    self.metadata_directory = self._generate_metadata()
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_internal\req\req_install.py", line 549, in _generate_metadata
    return generate_metadata(
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_internal\operations\build\metadata.py", line 36, in generate_metadata
    distinfo_dir = backend.prepare_metadata_for_build_wheel(
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_vendor\pep517\wrappers.py", line 167, in prepare_metadata_for_build_wheel
    return self._call_hook('prepare_metadata_for_build_wheel', {
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_vendor\pep517\wrappers.py", line 255, in _call_hook
    raise BackendUnavailable(data.get('traceback', ''))
pipenv.patched.notpip._vendor.pep517.wrappers.BackendUnavailable: Traceback (most recent call last):
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_vendor\pep517\_in_process.py", line 63, in _build_backend
    obj = import_module(mod_path)
  File "c:\users\chris\appdata\local\programs\python\python38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'poetry'

ROUND 1
Current constraints:
  flake8>=3.7 (from -r C:\Users\Chris\AppData\Local\Temp\pipenvgpsd96rurequirements\pipenv-8xkbw7k7-constraints.txt (line 3))
  flake8-annotations>=2.0 (from -r C:\Users\Chris\AppData\Local\Temp\pipenvgpsd96rurequirements\pipenv-8xkbw7k7-constraints.txt (line 2))

Finding the best candidates:
  found candidate flake8==3.7.9 (constraint was >=3.7)
  found candidate flake8-annotations==2.1.0 (constraint was >=2.0)

Finding secondary dependencies:
  flake8==3.7.9             requires entrypoints<0.4.0,>=0.3.0, mccabe<0.7.0,>=0.6.0, pycodestyle<2.6.0,>=2.5.0, pyflakes<2.2.0,>=2.1.0
  flake8-annotations==2.1.0 not in cache, need to check index
Traceback (most recent call last):
  File "c:/users/chris/appdata/local/programs/python/python38/lib/site-packages/pipenv/resolver.py", line 807, in <module>
    main()
  File "c:/users/chris/appdata/local/programs/python/python38/lib/site-packages/pipenv/resolver.py", line 802, in main
    _main(parsed.pre, parsed.clear, parsed.verbose, parsed.system, parsed.write,
  File "c:/users/chris/appdata/local/programs/python/python38/lib/site-packages/pipenv/resolver.py", line 785, in _main
    resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages)
  File "c:/users/chris/appdata/local/programs/python/python38/lib/site-packages/pipenv/resolver.py", line 746, in resolve_packages
    results, resolver = resolve(
  File "c:/users/chris/appdata/local/programs/python/python38/lib/site-packages/pipenv/resolver.py", line 728, in resolve
    return resolve_deps(
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\utils.py", line 1371, in resolve_deps
    results, hashes, markers_lookup, resolver, skipped = actually_resolve_deps(
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\utils.py", line 1086, in actually_resolve_deps
    resolver.resolve()
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\utils.py", line 807, in resolve
    results = self.resolver.resolve(max_rounds=environments.PIPENV_MAX_ROUNDS)
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\piptools\resolver.py", line 180, in resolve
    has_changed, best_matches = self._resolve_one_round()
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\piptools\resolver.py", line 268, in _resolve_one_round
    their_constraints.extend(self._iter_dependencies(best_match))
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\piptools\resolver.py", line 383, in _iter_dependencies
    dependencies = self.repository.get_dependencies(ireq)
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\piptools\repositories\pypi.py", line 226, in get_dependencies
    legacy_results = self.get_legacy_dependencies(ireq)
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\piptools\repositories\pypi.py", line 347, in get_legacy_dependencies
    results, ireq = self.resolve_reqs(
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\piptools\repositories\pypi.py", line 303, in resolve_reqs
    results = resolver._resolve_one(reqset, ireq)
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_internal\legacy_resolve.py", line 339, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_internal\legacy_resolve.py", line 287, in _get_abstract_dist_for
    abstract_dist = self.preparer.prepare_linked_requirement(req)
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_internal\operations\prepare.py", line 508, in prepare_linked_requirement
    abstract_dist = _get_prepared_distribution(
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_internal\operations\prepare.py", line 95, in _get_prepared_distribution
    abstract_dist.prepare_distribution_metadata(finder, build_isolation)
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_internal\distributions\sdist.py", line 40, in prepare_distribution_metadata
    self.req.prepare_metadata()
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_internal\req\req_install.py", line 564, in prepare_metadata
    self.metadata_directory = self._generate_metadata()
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_internal\req\req_install.py", line 549, in _generate_metadata
    return generate_metadata(
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_internal\operations\build\metadata.py", line 36, in generate_metadata
    distinfo_dir = backend.prepare_metadata_for_build_wheel(
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_vendor\pep517\wrappers.py", line 167, in prepare_metadata_for_build_wheel
    return self._call_hook('prepare_metadata_for_build_wheel', {
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_vendor\pep517\wrappers.py", line 255, in _call_hook
    raise BackendUnavailable(data.get('traceback', ''))
pipenv.patched.notpip._vendor.pep517.wrappers.BackendUnavailable: Traceback (most recent call last):
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\patched\notpip\_vendor\pep517\_in_process.py", line 63, in _build_backend
    obj = import_module(mod_path)
  File "c:\users\chris\appdata\local\programs\python\python38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'poetry'
Traceback (most recent call last):
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\utils.py", line 1109, in create_spinner
    yield sp
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\utils.py", line 1316, in venv_resolve_deps
    c = resolve(cmd, sp)
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\utils.py", line 1154, in resolve
    sys.exit(c.return_code)
SystemExit: 1

Output of pipenv --support

Pipenv version: '2020.4.1b1'

Pipenv location: 'c:\\users\\chris\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\pipenv'

Python location: 'c:\\users\\chris\\appdata\\local\\programs\\python\\python38\\python.exe'

Python installations found:

Traceback (most recent call last):
  File "c:\users\chris\appdata\local\programs\python\python38\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\chris\appdata\local\programs\python\python38\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "c:\users\chris\appdata\local\programs\python\python38\scripts\pipenv.exe\__main__.py", line 7, in <module>
  File "C:\Users\Chris\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\Chris\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "C:\Users\Chris\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 1236, in invoke
    return Command.invoke(self, ctx)
  File "C:\Users\Chris\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\Chris\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\Chris\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "C:\Users\Chris\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\Chris\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\cli\command.py", line 138, in cli
    get_pipenv_diagnostics()
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\help.py", line 33, in get_pipenv_diagnostics
    python_paths = finder.find_all_python_versions()
  File "c:\users\chris\appdata\local\programs\python\python38\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 328, in find_all_python_versions
    path_list = sorted(versions, key=version_sort, reverse=True)
AttributeError: 'NoneType' object has no attribute 'version_sort'

@frostming frostming added the Type: Bug 🐛 This issue is a bug. label Apr 30, 2020
@frostming
Copy link
Contributor

frostming commented Apr 30, 2020

The current workaround would be to install poetry into your venv. Then do pipenv clean after dependencies are installed

@techalchemy
Copy link
Member

this is another one where, on the master branch, I can't reproduce the error in question. Can you please test against master and confirm this is still a problem?

@techalchemy
Copy link
Member

As an update-- I am able to reproduce this against the prerelease, but not against master -- I believe this is because pep517 builders will generally produce wheels which means pipenv should generally not need to install the builder itself to parse metadata.

Since I can reproduce this and confirm that it is fixed, I will close this for now -- please reopen it if you find it is not fixed on master

Thanks for reporting this issue and for the reminder that it merits a look!

@doremifasollasi
Copy link

I created a virtual environment. Then I needed to install Apache Airflow. But the program stopped and reported an error (ModuleNotFoundError: No module named 'poetry').
The command $ pip install -U poetry helped me solve this problem.

@raleighlittles
Copy link

I created a virtual environment. Then I needed to install Apache Airflow. But the program stopped and reported an error (ModuleNotFoundError: No module named 'poetry'). The command $ pip install -U poetry helped me solve this problem.

This doesn't work for me on the latest version of Ubuntu, I get this error:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐛 This issue is a bug.
Projects
None yet
Development

No branches or pull requests

5 participants