iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > Python >python多版本py命令及虚拟环境管理
  • 146
分享到

python多版本py命令及虚拟环境管理

python开发语言vscode 2023-09-01 07:09:57 146人浏览 薄情痞子

Python 官方文档:入门教程 => 点击学习

摘要

创建虚拟环境失败, 已经很久没有用python3这个命令,可能又被系统环境修改的时候弄乱了.花点时间整理下 $ python3 -m venv ./venv Error: Command '[‘E:\

创建虚拟环境失败, 已经很久没有用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.3Requires-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.11ERROR: 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

./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://blog.csdn.net/zoeou/article/details/127745470

--结束END--

本文标题: python多版本py命令及虚拟环境管理

本文链接: https://www.lsjlt.com/news/387697.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作