创建虚拟环境失败, 已经很久没有用python3这个命令,可能又被系统环境修改的时候弄乱了.花点时间整理下
$ python3 -m venv ./venv
Error: Command '[‘E:\code\venv\Scripts\python.exe’, ‘-Im’, ‘ensurepip’, ‘–upgrade’, ‘–default-pip’ returned non-zero exit status 1.
把从windows store 下载的python3.8版本给卸了, 从官网下载python3.11
使用py 替代 python命令
默认py命令创建虚拟环境
$ py -m venv venv
进入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
又从官网下了python3.9
$ 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指定python版本,生成虚拟环境,目录下文件名为venv
$ py -3.9 -m venv venv
进入vscode
win
$ & e:/code/venv/Scripts/Activate.ps1
mac
$ source ./venv/bin/activate
退出
$ deactivate
$ pip3 install -r requirements.txt -i https://mirrors.ustc.edu.cn/pypi/web/simple/
正常完成requirements下载
centos安装python3.9
wget https://www.python.org/ftp/python/3.9.6/Python-3.9.6.tgz
tar -xf Python-3.9.6.tgz
cd Python-3.9.6文章来源:https://www.toymoban.com/news/detail-419287.html
./configure 或者 ./configure --enable-optimizations
问题: https://blog.csdn.net/hd243608836/article/details/121418565
make altinstall
注意使用altinstall而不是install,以避免覆盖系统默认的Python版本。
python3.9 --version
Python 3.9.6文章来源地址https://www.toymoban.com/news/detail-419287.html
到了这里,关于python多版本py命令及虚拟环境管理的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!