virtualenv-clone icon indicating copy to clipboard operation
virtualenv-clone copied to clipboard

virtualenv-clone doesn't work correctly on windows

Open limdauto opened this issue 5 years ago • 2 comments

When I call clonevirtualenv.clone_virtualenv on Windows, I got this error:

In [8]: clonevirtualenv.clone_virtualenv("D:\\anaconda3\\envs\\kedro-environment\\", str(tmpdir / "ked-install" ))
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-8-fb15ea24257a> in <module>
----> 1 clonevirtualenv.clone_virtualenv("D:\\anaconda3\\envs\\kedro-environment\\", str(tmpdir / "ked-install" ))

d:\anaconda3\envs\kedro-environment\lib\site-packages\clonevirtualenv.py in clone_virtualenv(src_dir, dst_dir)
     75     shutil.copytree(src_dir, dst_dir, symlinks=True,
     76             ignore=shutil.ignore_patterns('*.pyc'))
---> 77     version, sys_path = _virtualenv_sys(dst_dir)
     78     logger.info('fixing scripts in bin...')
     79     fixup_scripts(src_dir, dst_dir, version)

d:\anaconda3\envs\kedro-environment\lib\site-packages\clonevirtualenv.py in _virtualenv_sys(venv_path)
     58               'print ("\\n".join(sys.path));'],
     59         env={},
---> 60         stdout=subprocess.PIPE)
     61     stdout, err = p.communicate()
     62     assert not p.returncode and stdout

d:\anaconda3\envs\kedro-environment\lib\subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
    798                                 c2pread, c2pwrite,
    799                                 errread, errwrite,
--> 800                                 restore_signals, start_new_session)
    801         except:
    802             # Cleanup if the child failed starting.

d:\anaconda3\envs\kedro-environment\lib\subprocess.py in _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_start_new_session)
   1205                                          env,
   1206                                          os.fspath(cwd) if cwd is not None else None,
-> 1207                                          startupinfo)
   1208             finally:
   1209                 # Child is launched. Close the parent's copy of those pipe

FileNotFoundError: [WinError 2] The system cannot find the file specified

I have narrowed down one bug to be this line: https://github.com/edwardgeorge/virtualenv-clone/blob/master/clonevirtualenv.py#L52. There might be more. I'm still trying to confirm.

On Windows, at least on my Windows (Windows 10, python 3.7), there is no python executable in Scripts. There is python.exe in its parent directory though.

limdauto avatar Jul 17 '20 13:07 limdauto

@limdauto thanks for the report! If you can submit a PR that works for you, I'd be happy to merge something.

timabbott avatar Jul 14 '21 23:07 timabbott

Hi.

Same error.

Changing python to python.exe alone does not fix the problem. The env={} is also a problem in windows. At least PATH must be indicate.

I will submit a PR soon, tested on my PC (Windows 11, CPython 3.11).

ad-mcas avatar Aug 04 '23 09:08 ad-mcas