簡體   English   中英

MAC OS Monterey 上的 Virtualenv 問題

[英]Issues with Virtualenv on MAC OS Monterey

以下是導致 MAC OS Monterey 問題的代碼部分,它在以前的版本中運行良好

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)

嘗試使用 VirtualENV 版本 16.7.7、16.7.12、20.13.1 但沒有成功

以下是我得到的錯誤

-- 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

我在使用 pipenv 時遇到了類似的問題。 唯一為我修復它的是

pip install --upgrade virtualenv

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM