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

No module named '_hashlib' affecting poetry >= 1.4.0 #7695

Closed
4 tasks
dspangen opened this issue Mar 20, 2023 · 6 comments
Closed
4 tasks

No module named '_hashlib' affecting poetry >= 1.4.0 #7695

dspangen opened this issue Mar 20, 2023 · 6 comments
Labels
kind/bug Something isn't working as expected status/external-issue Issue is caused by external project (platform, dep, etc)

Comments

@dspangen
Copy link

  • Poetry version: 1.4.1 (began affecting 1.4.0)
  • Python version: 3.9.16
  • OS version and name: MacOS 13.2.1 (under both Rosetta and arm64 envs)
  • pyproject.toml: immaterial; can't even poetry install
  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

We started seeing this with 1.4.0. Fairly inscrutable module import error after install:

➜  backend git:(main) ✗ poetry self update
Updating Poetry version ...

Using version ^1.4.1 for poetry

Updating dependencies
Resolving dependencies... Downloading https://files.pythonhosted.org/packages/e5/ca/1172b6638d52f2d6caa2dd262ec4c811ba59eee96d54a7701930726bce18/install
Resolving dependencies... (4.2s)

Writing lock file

Package operations: 3 installs, 8 updates, 0 removals

  • Updating urllib3 (1.26.14 -> 1.26.15)
  • Updating filelock (3.9.0 -> 3.10.0)
  • Updating importlib-metadata (4.13.0 -> 6.1.0)
  • Updating poetry-core (1.4.0 -> 1.5.2)
  • Installing pyproject-hooks (1.0.0)
  • Installing build (0.10.0)
  • Updating dulwich (0.20.50 -> 0.21.3)
  • Installing installer (0.7.0)
  • Updating trove-classifiers (2023.2.20 -> 2023.3.9)
  • Updating virtualenv (20.20.0 -> 20.21.0)
  • Updating poetry (1.3.0 -> 1.4.1)
➜  backend git:(main) ✗ poetry install

No module named '_hashlib'
➜  backend git:(main) ✗ POETRY_VERSION=1.3.2 poetry self update

No module named '_hashlib'
@dspangen dspangen added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Mar 20, 2023
@dspangen dspangen changed the title No module named '_hashlib' affection poetry >= 1.4.0 No module named '_hashlib' affecting poetry >= 1.4.0 Mar 20, 2023
@dimbleby
Copy link
Contributor

hashlib is part of the python standard library, I can only guess that there is something funky about your python installation.

It is unlikely that there is anything the poetry project can do to resolve this.

@shunwen
Copy link

shunwen commented Mar 23, 2023

@dspangen I have the same issue on macOS (Apple M2). I installed python 3.9.16 using pyenv. It's related to OpenSSL dependency, and I managed to fix it by reinstalling python using the command CONFIGURE_OPTS="-with-openssl=/opt/homebrew/opt/openssl" pyenv install -v 3.9.16.

You might need to figure out your openssl path and install python again following this guide https://github.com/pyenv/pyenv/wiki/Common-build-problems#1-openssl-is-installed-to-an-uncommon-location

Since you mentioned that you are using poetry 1.4.1, you might hit this issue microsoft/debugpy#1246 after the _hashlib issue.

P.S. 1
I have these two lines in my .zshrc since years ago, but it seems they don't work in this case:

export LDFLAGS="-L/opt/homebrew/opt/openssl/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl/include"

P.S. 2
I use rbenv to install my rubies and had this line in .zshrc, and this works for rbenv.
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"

@Secrus Secrus added status/external-issue Issue is caused by external project (platform, dep, etc) and removed status/triage This issue needs to be triaged labels Apr 17, 2023
@Secrus
Copy link
Member

Secrus commented Apr 17, 2023

Not a Poetry issue

@Secrus Secrus closed this as not planned Won't fix, can't repro, duplicate, stale Apr 17, 2023
@mattotodd
Copy link

You are saying tis not poetry but i just tried upgrading poetry, it broke with the same error, so i tried downgrading and get the same error

mattotodd@bosco proj-platform % poetry self update 1.2.2
Configuration file exists at /Users/mattotodd/Library/Preferences/pypoetry, reusing this directory.

Consider moving TOML configuration files to /Users/mattotodd/Library/Application Support/pypoetry, as support for the legacy directory will be removed in an upcoming release.
Traceback (most recent call last):
  File "/Users/mattotodd/Library/Application Support/pypoetry/venv/lib/python3.9/site-packages/cleo/application.py", line 327, in run
    exit_code = self._run(io)
  File "/Users/mattotodd/Library/Application Support/pypoetry/venv/lib/python3.9/site-packages/poetry/console/application.py", line 190, in _run
    exit_code: int = super()._run(io)
  File "/Users/mattotodd/Library/Application Support/pypoetry/venv/lib/python3.9/site-packages/cleo/application.py", line 378, in _run
    name = self._get_command_name(io)
  File "/Users/mattotodd/Library/Application Support/pypoetry/venv/lib/python3.9/site-packages/cleo/application.py", line 610, in _get_command_name
    if self.has(candidate):
  File "/Users/mattotodd/Library/Application Support/pypoetry/venv/lib/python3.9/site-packages/cleo/application.py", line 232, in has
    self._command_loader.has(name) and self.add(self._command_loader.get(name))
  File "/Users/mattotodd/Library/Application Support/pypoetry/venv/lib/python3.9/site-packages/cleo/loaders/factory_command_loader.py", line 34, in get
    return factory()
  File "/Users/mattotodd/Library/Application Support/pypoetry/venv/lib/python3.9/site-packages/poetry/console/application.py", line 44, in _load
    module = import_module("poetry.console.commands." + ".".join(words))
  File "/Users/mattotodd/.pyenv/versions/3.9.10/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/Users/mattotodd/Library/Application Support/pypoetry/venv/lib/python3.9/site-packages/poetry/console/commands/self/update.py", line 8, in <module>
    from poetry.console.commands.add import AddCommand
  File "/Users/mattotodd/Library/Application Support/pypoetry/venv/lib/python3.9/site-packages/poetry/console/commands/add.py", line 13, in <module>
    from poetry.console.commands.init import InitCommand
  File "/Users/mattotodd/Library/Application Support/pypoetry/venv/lib/python3.9/site-packages/poetry/console/commands/init.py", line 16, in <module>
    from poetry.utils.dependency_specification import RequirementsParser
  File "/Users/mattotodd/Library/Application Support/pypoetry/venv/lib/python3.9/site-packages/poetry/utils/dependency_specification.py", line 19, in <module>
    from poetry.packages.direct_origin import DirectOrigin
  File "/Users/mattotodd/Library/Application Support/pypoetry/venv/lib/python3.9/site-packages/poetry/packages/direct_origin.py", line 14, in <module>
    from poetry.vcs.git import Git
  File "/Users/mattotodd/Library/Application Support/pypoetry/venv/lib/python3.9/site-packages/poetry/vcs/git/__init__.py", line 3, in <module>
    from poetry.vcs.git.backend import Git
  File "/Users/mattotodd/Library/Application Support/pypoetry/venv/lib/python3.9/site-packages/poetry/vcs/git/backend.py", line 12, in <module>
    from dulwich import porcelain
  File "/Users/mattotodd/Library/Application Support/pypoetry/venv/lib/python3.9/site-packages/dulwich/porcelain.py", line 79, in <module>
    from .client import get_transport_and_path
  File "/Users/mattotodd/Library/Application Support/pypoetry/venv/lib/python3.9/site-packages/dulwich/client.py", line 62, in <module>
    from .pack import (PACK_SPOOL_FILE_MAX_SIZE, PackChunkGenerator,
  File "/Users/mattotodd/Library/Application Support/pypoetry/venv/lib/python3.9/site-packages/dulwich/pack.py", line 78, in <module>
    from .objects import ObjectID, ShaFile, hex_to_sha, object_header, sha_to_hex
  File "/Users/mattotodd/Library/Application Support/pypoetry/venv/lib/python3.9/site-packages/dulwich/objects.py", line 36, in <module>
    from _hashlib import HASH
ModuleNotFoundError: No module named '_hashlib'

try removing poetry completely , same error:

mattotodd@bosco proj-platform % poetry self remove
Configuration file exists at /Users/mattotodd/Library/Preferences/pypoetry, reusing this directory.

Consider moving TOML configuration files to /Users/mattotodd/Library/Application Support/pypoetry, as support for the legacy directory will be removed in an upcoming release.

No module named '_hashlib'

@johnklehm
Copy link

johnklehm commented Jun 1, 2023

Just ran into this too, the fix was to uninstall python and reinstall with configure opts e.g.

  • asdf uninstall python 3.9.16
  • asdf uninstall poetry 1.5.1
  • export CONFIGURE_OPTS="--with-openssl=$(brew --prefix openssl)"
  • asdf install python 3.9.16
  • asdf install poetry 1.5.1

Copy link

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 Feb 29, 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 status/external-issue Issue is caused by external project (platform, dep, etc)
Projects
None yet
Development

No branches or pull requests

6 participants