Repository: pypa/virtualenv

Issue #1810: 20.0.19 Fails on CentOS 7/older Python 2 - AttributeError: 'module' object has no attribute 'get_makefile_name'
Created: 2020-05-04T05:30:10Z
Issue
20.0.19 fails on centos 7 with Python 2.7.5
-bash-4.2# virtualenv --version
Traceback (most recent call last):
  File "/usr/bin/virtualenv", line 5, in <module>
    from virtualenv.__main__ import run_with_catch
  File "/usr/lib/python2.7/site-packages/virtualenv/__init__.py", line 3, in <module>
    from .run import cli_run
  File "/usr/lib/python2.7/site-packages/virtualenv/run/__init__.py", line 12, in <module>
    from .plugin.creators import CreatorSelector
  File "/usr/lib/python2.7/site-packages/virtualenv/run/plugin/creators.py", line 6, in <module>
    from virtualenv.create.via_global_ref.builtin.builtin_way import VirtualenvBuiltin
  File "/usr/lib/python2.7/site-packages/virtualenv/create/via_global_ref/builtin/builtin_way.py", line 7, in <module>
    from virtualenv.create.creator import Creator
  File "/usr/lib/python2.7/site-packages/virtualenv/create/creator.py", line 14, in <module>
    from virtualenv.discovery.cached_py_info import LogCmd
  File "/usr/lib/python2.7/site-packages/virtualenv/discovery/cached_py_info.py", line 26, in <module>
    _CACHE[Path(sys.executable)] = PythonInfo()
  File "/usr/lib/python2.7/site-packages/virtualenv/discovery/py_info.py", line 82, in __init__
    ("makefile_filename", sysconfig.get_makefile_filename()),
AttributeError: 'module' object has no attribute 'get_makefile_filename'

Seems to be from dfafc11 which introduced the usage of this call.  After reading https://bugs.python.org/issue22199, it appears this might be _ prefixed on some platforms with older Python, such as CentOS 7 (looks like it only got renamed for 2.7.9?)

Duplicate issue #1812: 20.0.19(with python2.7.5) fails with AttributeError: 'module' object has no attribute 'get_makefile_filename'
Created: 2020-05-04T05:38:43Z
virtualenv 20.0.19 do not work with python2.7.5 and fails with below Traceback:-
[centos@centos7venv ~]$ virtualenv --help
Traceback (most recent call last):
File "/home/centos/.local/bin/virtualenv", line 5, in 
from virtualenv.main import run_with_catch
File "/home/centos/.local/lib/python2.7/site-packages/virtualenv/init.py", line 3, in 
from .run import cli_run
File "/home/centos/.local/lib/python2.7/site-packages/virtualenv/run/init.py", line 12, in 
from .plugin.creators import CreatorSelector
File "/home/centos/.local/lib/python2.7/site-packages/virtualenv/run/plugin/creators.py", line 6, in 
from virtualenv.create.via_global_ref.builtin.builtin_way import VirtualenvBuiltin
File "/home/centos/.local/lib/python2.7/site-packages/virtualenv/create/via_global_ref/builtin/builtin_way.py", line 7, in 
from virtualenv.create.creator import Creator
File "/home/centos/.local/lib/python2.7/site-packages/virtualenv/create/creator.py", line 14, in 
from virtualenv.discovery.cached_py_info import LogCmd
File "/home/centos/.local/lib/python2.7/site-packages/virtualenv/discovery/cached_py_info.py", line 26, in 
_CACHE[Path(sys.executable)] = PythonInfo()
File "/home/centos/.local/lib/python2.7/site-packages/virtualenv/discovery/py_info.py", line 82, in init
("makefile_filename", sysconfig.get_makefile_filename()),
AttributeError: 'module' object has no attribute 'get_makefile_filename'
[centos@centos7venv ~]$ python --version
Python 2.7.5
[centos@centos7venv ~]$ cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
Environment
Provide at least:

OS: CentOS7.7
Python Version: 2.7.5
pip list of the host python where virtualenv is installed:
[centos@centos7venv ~]$ pip list
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Package                          Version


appdirs                          1.4.3
Babel                            0.9.6
backports.ssl-match-hostname     3.5.0.1
chardet                          2.2.1
cloud-init                       18.5
configobj                        4.7.2
configparser                     4.0.2
contextlib2                      0.6.0.post1
decorator                        3.4.0
distlib                          0.3.0
filelock                         3.0.12
importlib-metadata               1.6.0
importlib-resources              1.5.0
iniparse                         0.4
ipaddress                        1.0.16
IPy                              0.75
Jinja2                           2.7.2
jsonpatch                        1.2
jsonpointer                      1.9
kitchen                          1.1.1
MarkupSafe                       0.11
pathlib2                         2.3.5
perf                             0.1
pip                              20.1
policycoreutils-default-encoding 0.1
prettytable                      0.7.2
pycurl                           7.19.0
pygobject                        3.22.0
pygpgme                          0.3
pyliblzma                        0.5.3
pyserial                         2.6
python-linux-procfs              0.4.9
pyudev                           0.15
pyxattr                          0.5.1
PyYAML                           3.10
requests                         2.6.0
scandir                          1.10.0
schedutils                       0.4
seobject                         0.1
sepolicy                         1.1
setuptools                       0.9.8
singledispatch                   3.4.0.3
six                              1.9.0
typing                           3.7.4.1
urlgrabber                       3.10
urllib3                          1.10.2
virtualenv                       20.0.19
wheel                            0.34.2
yum-metadata-parser              1.1.4
zipp                             1.2.0

Output of the virtual environment creation
Make sure to run the creation with -vvv --with-traceback:
[centos@centos7venv ~]$ virtualenv -vvv --with-traceback testvenv
Traceback (most recent call last):
  File "/home/centos/.local/bin/virtualenv", line 5, in <module>
    from virtualenv.__main__ import run_with_catch
  File "/home/centos/.local/lib/python2.7/site-packages/virtualenv/__init__.py", line 3, in <module>
    from .run import cli_run
  File "/home/centos/.local/lib/python2.7/site-packages/virtualenv/run/__init__.py", line 12, in <module>
    from .plugin.creators import CreatorSelector
  File "/home/centos/.local/lib/python2.7/site-packages/virtualenv/run/plugin/creators.py", line 6, in <module>
    from virtualenv.create.via_global_ref.builtin.builtin_way import VirtualenvBuiltin
  File "/home/centos/.local/lib/python2.7/site-packages/virtualenv/create/via_global_ref/builtin/builtin_way.py", line 7, in <module>
    from virtualenv.create.creator import Creator
  File "/home/centos/.local/lib/python2.7/site-packages/virtualenv/create/creator.py", line 14, in <module>
    from virtualenv.discovery.cached_py_info import LogCmd
  File "/home/centos/.local/lib/python2.7/site-packages/virtualenv/discovery/cached_py_info.py", line 26, in <module>
    _CACHE[Path(sys.executable)] = PythonInfo()
  File "/home/centos/.local/lib/python2.7/site-packages/virtualenv/discovery/py_info.py", line 82, in __init__
    ("makefile_filename", sysconfig.get_makefile_filename()),
AttributeError: 'module' object has no attribute 'get_makefile_filename'
https://github.com/pypa/virtualenv/pull/1787/files caused the issue as it assumed get_makefile_filename is present in all python2 versions.

Closing comment (2020-05-04T05:42:07Z): Same timing, duplicate of #1810, so can be closed.