Comando py de varias versiones de Python y gestión de entornos virtuales

No se pudo crear un entorno virtual. Ha pasado mucho tiempo desde que utilicé el comando python3, y es posible que se haya estropeado cuando se modificó el entorno del sistema. Tómese un tiempo para solucionarlo.

$ python3 -m venv ./venv

Error: el comando '['E:\code\venv\Scripts\python.exe', '-Im', 'ensurepip', '–upgrade', '–default-pip' devolvió un estado de salida distinto de cero 1.

Desinstale la versión python3.8 descargada de la tienda de Windows y descargue python3.11 del sitio web oficial

Use py en lugar de los comandos de python

El comando py predeterminado crea un entorno virtual
$ py -m venv venv
enter vscode
& e:/code/venv/Scripts/Activate.ps1
$ pip3 install -r requirements.txt -i https://mirrors.ustc.edu.cn /pypi /web/simple/

ERROR: Ignored the following versions that require a different python version: 1.21.2 Requires-Python >=3.7,<3.11; 1.21.3
Requires-Python >=3.7,<3.11; 1.21.4 Requires-Python >=3.7,<3.11; 1.21.5 Requires-Python >=3.7,<3.11; 1.21.6 Requires-Python >=3.7,<3.11; 1.6.2 Requires-Python >=3.7,<3.10; 1.6.3 Requires-Python >=3.7,<3.10; 1.7.0 Requires-Python >=3.7,<3.10; 1.7.0rc1 Requires-Python >=3.7,<3.10; 1.7.0rc2 Requires-Python >=3.7,<3.10; 1.7.1 Requires-Python >=3.7,<3.10; 1.7.2 Requires-Python >=3.7,<3.11; 1.7.3 Requires-Python >=3.7,<3.11; 1.8.0 Requires-Python >=3.8,<3.11; 1.8.0rc1 Requires-Python >=3.8,<3.11; 1.8.0rc2 Requires-Python >=3.8,<3.11; 1.8.0rc3 Requires-Python >=3.8,<3.11; 1.8.0rc4 Requires-Python >=3.8,<3.11;
1.8.1 Requires-Python >=3.8,<3.11
ERROR: Could not find a version that satisfies the requirement torch>=1.7.0 (from versions: none)
ERROR: No matching distribution found for torch>=1.7.0

Descargado python3.9 desde el sitio web oficial de nuevo

$ py --list
-V:3.11 *        Python 3.11 (64-bit)
-V:3.9           Python 3.9 (64-bit)
-V:3.6-32        Python 3.6 (32-bit)# win10系统自带的.无法卸载
-V:2.7 # 老项目使用,这个环境不能动

py especifica la versión de python, genera un entorno virtual y el nombre del archivo en el directorio es venv
$ py -3.9 -m venv venv
ingresa vscode

win
& e:/code/venv/Scripts/Activate.ps1
mac
source ./venv/bin/activate

$ pip3 install -r requisitos.txt -i https://mirrors.ustc.edu.cn/pypi/web/simple/

Complete la descarga de requisitos normalmente

Supongo que te gusta

Origin blog.csdn.net/zoeou/article/details/127745470
Recomendado
Clasificación