This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Compiling from source prints «ModuleNotFoundError: No module named 'binascii'»
Type: compile error Stage: resolved
Components: Installation Versions: Python 3.10
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, dilyan.palauzov
Priority: normal Keywords:

Created on 2022-01-30 08:52 by dilyan.palauzov, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg412134 - (view) Author: Дилян Палаузов (dilyan.palauzov) Date: 2022-01-30 08:52
I compile python from source:

$ python --version
Python 3.10.1+
$ cat /etc/ 
$ git describe 
$ ./configure --enable-loadable-sqlite-extensions --disable-ipv6 --with-system-expat --with-system-libmpdec --enable-shared
$ make
gcc -c -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden  -I./Include/internal  -I. -I./Include   -fPIC -DPy_BUILD_CORE -o Modules/_math.o Modules/_math.c
LD_LIBRARY_PATH=/git/cpython CC='gcc' LDSHARED='gcc -shared    ' OPT='-DNDEBUG -g -fwrapv -O3 -Wall'    _TCLTK_INCLUDES='-I/usr/local/include' _TCLTK_LIBS='-L/usr/local/lib -ltk8.6 -ltkstub8.6 -ltcl8.6 -ltclstub8.6'         ./python -E ./  build
Traceback (most recent call last):
  File "/git/cpython/./", line 50, in <module>
    from distutils.command.install import install
  File "/usr/local/lib/python3.10/site-packages/setuptools/_distutils/command/", line 20, in <module>
    from .. import _collections
  File "/usr/local/lib/python3.10/site-packages/setuptools/", line 16, in <module>
    import setuptools.version
  File "/usr/local/lib/python3.10/site-packages/setuptools/", line 1, in <module>
    import pkg_resources
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/", line 23, in <module>
    import zipfile
  File "/git/cpython/Lib/", line 6, in <module>
    import binascii
ModuleNotFoundError: No module named 'binascii'
make: *** [Makefile:637: sharedmods] Error 1

When I compiled python 3.10 using python 3.8 one or two months ago, there was no such problem.

Compiling python from source code, shall use the bundled distutils, not the installed one.

My Linux From Scratch system appears not to have module binascii:

$ locate binascii
msg412138 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2022-01-30 11:02
You are affected by setuptools bug . The setuptools issues has a workaround. The next version of setuptools will come with a fix.
msg412142 - (view) Author: Дилян Палаузов (dilyan.palauzov) Date: 2022-01-30 12:45
The problem is, that Python’s install target depends on the system-wide setuptools, if there is system-wide setuptools.  If there is no system-wide installed setuptools, apparently the installation works flawlessly.

The solution is to tweak the source code of Python, not to depend on (system-wide installed) Python code outside of Python’s tarball.
msg412143 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2022-01-30 13:10
CPython's build system does not depend on setuptools.

The problem is that setuptools 60.0 introduced a .pth file and _distutils_hack to inject itself into Python import system. Under some circumstances Python's build system is affected by the hack and breaks.
Date User Action Args
2022-04-11 14:59:55adminsetgithub: 90737
2022-01-30 13:10:09christian.heimessetmessages: + msg412143
2022-01-30 12:45:33dilyan.palauzovsetmessages: + msg412142
2022-01-30 11:02:51christian.heimessetstatus: open -> closed

nosy: + christian.heimes
messages: + msg412138

resolution: third party
stage: resolved
2022-01-30 08:52:22dilyan.palauzovcreate