Issues with Virtualenv on MAC OS Monterey

Following is the code part which is causing the issue on MAC OS Monterey, which works fine in previous versions

VIRTUALENV_VERSION = '20.13.1'
VIRTUALENV_ARCHIVE = 'virtualenv-'+VIRTUALENV_VERSION+'.tar.gz'
VIRTUALENV_DOWNLOAD_URL = 'https://pypi.python.org/packages/source/v/virtualenv/'+VIRTUALENV_ARCHIVE
VIRTUALENV_ARCHIVE_SHA256 = 'e0621bcbf4160e4e1030f05065c8834b4e93f4fcc223255db2a823440aca9c14'

def create_virtualenv(tmp_dir, install_dir):
    download_location = os.path.join(tmp_dir, VIRTUALENV_ARCHIVE)
    print_status('Downloading virtualenv package from {}.'.format(VIRTUALENV_DOWNLOAD_URL))
    response = urlopen(VIRTUALENV_DOWNLOAD_URL)
    with open(download_location, 'wb') as f: f.write(response.read())
    print_status("Downloaded virtualenv package to {}.".format(download_location))
    if is_valid_sha256sum(download_location, VIRTUALENV_ARCHIVE_SHA256):
        print_status("Checksum of {} OK.".format(download_location))
    else:
        raise CLIInstallError("The checksum of the downloaded virtualenv package does not match.")
    print_status("Extracting '{}' to '{}'.".format(download_location, tmp_dir))
    package_tar = tarfile.open(download_location)
    package_tar.extractall(path=tmp_dir)
    package_tar.close()
    virtualenv_dir_name = 'virtualenv-'+VIRTUALENV_VERSION
    working_dir = os.path.join(tmp_dir, virtualenv_dir_name)
    cmd = [sys.executable, 'virtualenv.py', '--python', sys.executable, install_dir]
    exec_command(cmd, cwd=working_dir)

Tried with VirtualENV version 16.7.7, 16.7.12, 20.13.1 but no luck

Following is the error which I am getting

-- Verifying Python version.
-- Python version 3.8.9 okay.
-- Downloading virtualenv package from https://pypi.python.org/packages/source/v/virtualenv/virtualenv-16.7.7.tar.gz.
-- Downloaded virtualenv package to /var/folders/5w/dshk44h14g1_x782v3h4k38h0000gn/T/tmp8gf_ttw0/virtualenv-16.7.7.tar.gz.
-- Checksum of /var/folders/5w/dshk44h14g1_x782v3h4k38h0000gn/T/tmp8gf_ttw0/virtualenv-16.7.7.tar.gz OK.
-- Extracting '/var/folders/5w/dshk44h14g1_x782v3h4k38h0000gn/T/tmp8gf_ttw0/virtualenv-16.7.7.tar.gz' to '/var/folders/5w/dshk44h14g1_x782v3h4k38h0000gn/T/tmp8gf_ttw0'.
-- Executing: ['/Library/Developer/CommandLineTools/usr/bin/python3', 'virtualenv.py', '--python', '/Library/Developer/CommandLineTools/usr/bin/python3', '/Users/apple/ClientScriptsForMacOS/az']
Already using interpreter /Library/Developer/CommandLineTools/usr/bin/python3
Using base prefix '/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8'
New python executable in /Users/apple/ClientScriptsForMacOS/az/bin/python3
Not overwriting existing python script /Users/apple/ClientScriptsForMacOS/az/bin/python (you must use /Users/apple/ClientScriptsForMacOS/az/bin/python3)
ERROR: The executable /Users/apple/ClientScriptsForMacOS/az/bin/python3 is not functioning
ERROR: It thinks sys.prefix is '/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8' (should be '/Users/apple/ClientScriptsForMacOS/az')
ERROR: virtualenv is not compatible with this system or executable

Upvotes: 0

Views: 1098

Answers (1)

Jackson Bush
Jackson Bush

Reputation: 71

I was having a similar issue with pipenv. The only thing that fixed it for me was

pip install --upgrade virtualenv

Upvotes: 3

Related Questions