Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save facundobatista/ca885c27b29b538610f9dbfdd60f1920 to your computer and use it in GitHub Desktop.
Save facundobatista/ca885c27b29b538610f9dbfdd60f1920 to your computer and use it in GitHub Desktop.
venv.create not working
================================== FAILURES ===================================
______________________________ test_create_venv _______________________________
tmp_path = WindowsPath('C:/Users/runneradmin/AppData/Local/Temp/pytest-of-runneradmin/pytest-0/test_create_venv0')
def test_create_venv(tmp_path):
"""Test to show that venv.create doesn't work in Github Actions."""
import venv
> venv.create(str(tmp_path), with_pip=True)
D:\a\pyempaq\pyempaq\tests\test_integration.py:92:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\hostedtoolcache\windows\Python\3.9.6\x64\lib\venv\__init__.py:412: in create
builder.create(env_dir)
C:\hostedtoolcache\windows\Python\3.9.6\x64\lib\venv\__init__.py:75: in create
self._setup_pip(context)
C:\hostedtoolcache\windows\Python\3.9.6\x64\lib\venv\__init__.py:298: in _setup_pip
subprocess.check_output(cmd, stderr=subprocess.STDOUT)
C:\hostedtoolcache\windows\Python\3.9.6\x64\lib\subprocess.py:424: in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
C:\hostedtoolcache\windows\Python\3.9.6\x64\lib\subprocess.py:505: in run
with Popen(*popenargs, **kwargs) as process:
C:\hostedtoolcache\windows\Python\3.9.6\x64\lib\subprocess.py:951: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Popen: returncode: None args: ['C:\\Users\\runneradmin\\AppData\\Local\\Tem...>
args = 'C:\\Users\\runneradmin\\AppData\\Local\\Temp\\pytest-of-runneradmin\\pytest-0\\test_create_venv0\\Scripts\\python3.exe -Im ensurepip --upgrade --default-pip'
executable = None, preexec_fn = None, close_fds = False, pass_fds = ()
cwd = None, env = None
startupinfo = <subprocess.STARTUPINFO object at 0x0000021B29558C40>
creationflags = 0, shell = False, p2cread = Handle(616), p2cwrite = -1
c2pread = 11, c2pwrite = Handle(628), errread = -1, errwrite = Handle(672)
unused_restore_signals = True, unused_gid = None, unused_gids = None
unused_uid = None, unused_umask = -1, unused_start_new_session = False
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
unused_restore_signals,
unused_gid, unused_gids, unused_uid,
unused_umask,
unused_start_new_session):
"""Execute program (MS Windows version)"""
assert not pass_fds, "pass_fds not supported on Windows."
if isinstance(args, str):
pass
elif isinstance(args, bytes):
if shell:
raise TypeError('bytes args is not allowed on Windows')
args = list2cmdline([args])
elif isinstance(args, os.PathLike):
if shell:
raise TypeError('path-like args is not allowed when '
'shell is true')
args = list2cmdline([args])
else:
args = list2cmdline(args)
if executable is not None:
executable = os.fsdecode(executable)
# Process startup details
if startupinfo is None:
startupinfo = STARTUPINFO()
else:
# bpo-34044: Copy STARTUPINFO since it is modified above,
# so the caller can reuse it multiple times.
startupinfo = startupinfo.copy()
use_std_handles = -1 not in (p2cread, c2pwrite, errwrite)
if use_std_handles:
startupinfo.dwFlags |= _winapi.STARTF_USESTDHANDLES
startupinfo.hStdInput = p2cread
startupinfo.hStdOutput = c2pwrite
startupinfo.hStdError = errwrite
attribute_list = startupinfo.lpAttributeList
have_handle_list = bool(attribute_list and
"handle_list" in attribute_list and
attribute_list["handle_list"])
# If we were given an handle_list or need to create one
if have_handle_list or (use_std_handles and close_fds):
if attribute_list is None:
attribute_list = startupinfo.lpAttributeList = {}
handle_list = attribute_list["handle_list"] = \
list(attribute_list.get("handle_list", []))
if use_std_handles:
handle_list += [int(p2cread), int(c2pwrite), int(errwrite)]
handle_list[:] = self._filter_handle_list(handle_list)
if handle_list:
if not close_fds:
warnings.warn("startupinfo.lpAttributeList['handle_list'] "
"overriding close_fds", RuntimeWarning)
# When using the handle_list we always request to inherit
# handles but the only handles that will be inherited are
# the ones in the handle_list
close_fds = False
if shell:
startupinfo.dwFlags |= _winapi.STARTF_USESHOWWINDOW
startupinfo.wShowWindow = _winapi.SW_HIDE
comspec = os.environ.get("COMSPEC", "cmd.exe")
args = '{} /c "{}"'.format (comspec, args)
if cwd is not None:
cwd = os.fsdecode(cwd)
sys.audit("subprocess.Popen", executable, args, cwd, env)
# Start the process
try:
> hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
# no special security
None, None,
int(not close_fds),
creationflags,
env,
cwd,
startupinfo)
E FileNotFoundError: [WinError 2] The system cannot find the file specified
C:\hostedtoolcache\windows\Python\3.9.6\x64\lib\subprocess.py:1420: FileNotFoundError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment