I've seen that there has been a lot of work put in already to make virtualenv run under arm64 + MacOS 12, so thanks for that :) Unfortunately, I'm still running into an issue when trying to create a Python 2 virtualenv on my M1 MacBook. The error is an "TypeError: execv() arg 2 must contain only strings" and seems to happen when trying to copy the python executable for codesigning. I hope someone here can help me resolve that. I might also be able to help out with a PR, but would appreciate any guidance you can already give 😁
53 setup logging to NOTSET [DEBUG report:39]
65 find interpreter for spec PythonSpec(path=/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python) [INFO builtin:62]
65 proposed PythonInfo({'base_exec_prefix': None, 'system_stdlib': u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', 'has_venv': False, 'prefix': u'/System/Library/Frameworks/Python.framework/Versions/2.7', 'stdout_encoding': u'UTF-8', 'executable': '/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python', 'implementation': u'CPython', 'exec_prefix': u'/System/Library/Frameworks/Python.framework/Versions/2.7', 'platform': u'darwin', 'version': u'2.7.18 (default, Oct 2 2021, 04:20:38) \n[GCC Apple LLVM 13.0.0 (clang-1300.0.29.1) [+internal-os, ptrauth-isa=deploymen', 'sysconfig_paths': {u'platstdlib': u'{platbase}/lib/python{py_version_short}', u'platlib': u'{platbase}/lib/python{py_version_short}/site-packages', u'purelib': u'{base}/lib/python{py_version_short}/site-packages', u'stdlib': u'{base}/lib/python{py_version_short}', u'scripts': u'{base}/bin', u'include': u'{base}/include/python{py_version_short}', u'data': u'{base}'}, 'sysconfig_scheme': None, 'base_prefix': None, 'system_stdlib_platform': u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', 'file_system_encoding': u'utf-8', 'version_info': VersionInfo(major=2, minor=7, micro=18, releaselevel=u'final', serial=0), 'sysconfig_vars': {u'base': u'/System/Library/Frameworks/Python.framework/Versions/2.7', u'platbase': u'/System/Library/Frameworks/Python.framework/Versions/2.7', u'PYTHONFRAMEWORK': u'Python', u'py_version_short': u'2.7'}, 'path': [u'/usr/local/bin', u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', u'/Users/peter/Library/Python/2.7/lib/python/site-packages', u'/Library/Python/2.7/site-packages', u'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', u'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', u'/Library/Python/2.7/site-packages/virtualenv-20.13.0-py2.7.egg'], 'max_size': 9223372036854775807, 'sysconfig': {u'makefile_filename': u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/Makefile'}, 'real_prefix': None, 'distutils_install': {u'purelib': u'lib/python2.7/site-packages', u'headers': u'include/python2.7/UNKNOWN', u'platlib': u'lib/python2.7/site-packages', u'data': u'', u'scripts': u'bin'}, 'architecture': 64, 'original_executable': u'/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python', 'os': u'posix', 'system_executable': u'/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python'}) [INFO builtin:69]
65 accepted PythonInfo({'base_exec_prefix': None, 'system_stdlib': u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', 'has_venv': False, 'prefix': u'/System/Library/Frameworks/Python.framework/Versions/2.7', 'stdout_encoding': u'UTF-8', 'executable': '/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python', 'implementation': u'CPython', 'exec_prefix': u'/System/Library/Frameworks/Python.framework/Versions/2.7', 'platform': u'darwin', 'version': u'2.7.18 (default, Oct 2 2021, 04:20:38) \n[GCC Apple LLVM 13.0.0 (clang-1300.0.29.1) [+internal-os, ptrauth-isa=deploymen', 'sysconfig_paths': {u'platstdlib': u'{platbase}/lib/python{py_version_short}', u'platlib': u'{platbase}/lib/python{py_version_short}/site-packages', u'purelib': u'{base}/lib/python{py_version_short}/site-packages', u'stdlib': u'{base}/lib/python{py_version_short}', u'scripts': u'{base}/bin', u'include': u'{base}/include/python{py_version_short}', u'data': u'{base}'}, 'sysconfig_scheme': None, 'base_prefix': None, 'system_stdlib_platform': u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', 'file_system_encoding': u'utf-8', 'version_info': VersionInfo(major=2, minor=7, micro=18, releaselevel=u'final', serial=0), 'sysconfig_vars': {u'base': u'/System/Library/Frameworks/Python.framework/Versions/2.7', u'platbase': u'/System/Library/Frameworks/Python.framework/Versions/2.7', u'PYTHONFRAMEWORK': u'Python', u'py_version_short': u'2.7'}, 'path': [u'/usr/local/bin', u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', u'/Users/peter/Library/Python/2.7/lib/python/site-packages', u'/Library/Python/2.7/site-packages', u'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', u'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', u'/Library/Python/2.7/site-packages/virtualenv-20.13.0-py2.7.egg'], 'max_size': 9223372036854775807, 'sysconfig': {u'makefile_filename': u'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/Makefile'}, 'real_prefix': None, 'distutils_install': {u'purelib': u'lib/python2.7/site-packages', u'headers': u'include/python2.7/UNKNOWN', u'platlib': u'lib/python2.7/site-packages', u'data': u'', u'scripts': u'bin'}, 'architecture': 64, 'original_executable': u'/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python', 'os': u'posix', 'system_executable': u'/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python'}) [DEBUG builtin:71]
70 filesystem is not case-sensitive [DEBUG info:29]
108 create virtual environment via CPython2macOsArmFramework(dest=/Users/peter/path/venv, clear=False, no_vcs_ignore=False, global=False) [INFO session:52]
108 write /Users/peter/path/venv/pyvenv.cfg [DEBUG pyenv_cfg:34]
108 home = /System/Library/Frameworks/Python.framework/Versions/2.7 [DEBUG pyenv_cfg:38]
108 implementation = CPython [DEBUG pyenv_cfg:38]
108 version_info = 2.7.18.final.0 [DEBUG pyenv_cfg:38]
108 virtualenv = 20.13.0 [DEBUG pyenv_cfg:38]
108 include-system-site-packages = false [DEBUG pyenv_cfg:38]
108 base-prefix = /System/Library/Frameworks/Python.framework/Versions/2.7 [DEBUG pyenv_cfg:38]
108 base-exec-prefix = /System/Library/Frameworks/Python.framework/Versions/2.7 [DEBUG pyenv_cfg:38]
108 base-executable = /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python [DEBUG pyenv_cfg:38]
108 remove file /Users/peter/path/venv/bin/python [DEBUG _sync:37]
108 copy /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python to /Users/peter/path/venv/bin/python [DEBUG _sync:51]
109 remove file /Users/peter/path/venv/lib/python2.7/os.py [DEBUG _sync:37]
109 symlink /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py to /Users/peter/path/venv/lib/python2.7/os.py [DEBUG _sync:43]
109 remove file /Users/peter/path/venv/lib/python2.7/os.pyc [DEBUG _sync:37]
109 symlink /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.pyc to /Users/peter/path/venv/lib/python2.7/os.pyc [DEBUG _sync:43]
109 remove file /Users/peter/path/venv/include/python2.7 [DEBUG _sync:37]
110 symlink directory /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 to /Users/peter/path/venv/include/python2.7 [DEBUG _sync:43]
110 remove file /Users/peter/path/venv/lib/python2.7/config/Makefile [DEBUG _sync:37]
110 symlink /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/Makefile to /Users/peter/path/venv/lib/python2.7/config/Makefile [DEBUG _sync:43]
110 remove file /Users/peter/path/venv/.Python [DEBUG _sync:37]
110 symlink /System/Library/Frameworks/Python.framework/Versions/2.7/Python to /Users/peter/path/venv/.Python [DEBUG _sync:43]
110 remove file /Users/peter/path/venv/lib/python2.7/lib-dynload [DEBUG _sync:37]
110 symlink directory /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload to /Users/peter/path/venv/lib/python2.7/lib-dynload [DEBUG _sync:43]
110 create virtualenv import hook file /Users/peter/path/venv/lib/python2.7/site-packages/_virtualenv.pth [DEBUG api:95]
110 create /Users/peter/path/venv/lib/python2.7/site-packages/_virtualenv.py [DEBUG api:98]
111 change Mach-O for /Users/peter/path/venv/bin/python from /System/Library/Frameworks/Python.framework/Versions/2.7/Python to @executable_path/../.Python [DEBUG mac_os:201]
111 Changing signature of copied python exe /Users/peter/path/venv/bin/python [DEBUG mac_os:132]
115 Could not change MacOS code signing on copied python exe at /Users/peter/path/venv/bin/python [CRITICAL mac_os:144]
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 11, in <module>
load_entry_point('virtualenv==20.13.0', 'console_scripts', 'virtualenv')()
File "/Library/Python/2.7/site-packages/virtualenv-20.13.0-py2.7.egg/virtualenv/__main__.py", line 65, in run_with_catch
run(args, options, env)
File "/Library/Python/2.7/site-packages/virtualenv-20.13.0-py2.7.egg/virtualenv/__main__.py", line 18, in run
session = cli_run(args, options, env)
File "/Library/Python/2.7/site-packages/virtualenv-20.13.0-py2.7.egg/virtualenv/run/__init__.py", line 32, in cli_run
of_session.run()
File "/Library/Python/2.7/site-packages/virtualenv-20.13.0-py2.7.egg/virtualenv/run/session.py", line 46, in run
self._create()
File "/Library/Python/2.7/site-packages/virtualenv-20.13.0-py2.7.egg/virtualenv/run/session.py", line 53, in _create
self.creator.run()
File "/Library/Python/2.7/site-packages/virtualenv-20.13.0-py2.7.egg/virtualenv/create/creator.py", line 171, in run
self.create()
File "/Library/Python/2.7/site-packages/virtualenv-20.13.0-py2.7.egg/virtualenv/create/via_global_ref/builtin/cpython/mac_os.py", line 122, in create
self.fix_signature()
File "/Library/Python/2.7/site-packages/virtualenv-20.13.0-py2.7.egg/virtualenv/create/via_global_ref/builtin/cpython/mac_os.py", line 137, in fix_signature
subprocess.check_call(["cp", exe, bak_dir])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 185, in check_call
retcode = call(*popenargs, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 172, in call
return Popen(*popenargs, **kwargs).wait()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 394, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1047, in _execute_child
raise child_exception
TypeError: execv() arg 2 must contain only strings
Issue
I've seen that there has been a lot of work put in already to make virtualenv run under arm64 + MacOS 12, so thanks for that :) Unfortunately, I'm still running into an issue when trying to create a Python 2 virtualenv on my M1 MacBook. The error is an "TypeError: execv() arg 2 must contain only strings" and seems to happen when trying to copy the python executable for codesigning. I hope someone here can help me resolve that. I might also be able to help out with a PR, but would appreciate any guidance you can already give 😁
Environment
pip listof the host python wherevirtualenvis installed:Output of the virtual environment creation