The link posted by @chepner points to the default behaviour by OS.
- NT (windows): do not use symlinks (copy)
- otherwise (mac, linux, etc): use symlinks (don't copy)
if os.name == 'nt':
use_symlinks = False
else:
use_symlinks = True
use_symlinks
is used by both of the mutually exclusive arguments --symlinks
and --copies
as a default option value (ie when the option is not specified on the CLI). Both these options store their value to the options object as symlinks
with the appropriate truthiness depending on which option was used.
You can see the logic to copy or symlink depending on OS and this symlinks
CLI option value is here.
Point is. Copies does work on non-windows systems. Something else is going on. It is possible you have a python binary in your venv directory that was copied into place from an incompatible system or that there is some soft-linking in the binary and the things that binary points to don't exist on the current system.
First thing to check is whether you have copies or symlinks in your virtual directory (e.g. ls -l venv/bin
). If you have copies and not symlinks, try running the pythons: venv/bin/python3
and see if you still get an error. If you get an error it is an issue with the binary (not compatible with OS/arch or missing soft-linked libraries).
Copying around venv directories can have a bunch of problems. If you want to do this in a build/CI process make sure you really have the same os/system/arch on the CI as the destination machine and make sure you are working with copies and not symlinks. For activation and running python, make sure you update your PATH to include the venv python first export PATH="${PWD}/venv/bin:$PATH"
venv
,--copies
looks like a no-op unless you are using Windows. – Stupefacient--copies
usesstore_false
as its action, which just storesFalse
in the destination, regardless of what is already there, so it's a no-op if the default is alreadyFalse
. – Stupefacient