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


    创建虚拟环境失败, 已经很久没有用python3这个命令,可能又被系统环境修改的时候弄乱了.花点时间整理下

    $ python3 -m venv ./venv
    
    • 1

    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
    
    • 1
    • 2
    • 3
    • 4
    • 5

    又从官网下了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 # 老项目使用,这个环境不能动
    
    • 1
    • 2
    • 3
    • 4
    • 5

    py指定python版本,生成虚拟环境,目录下文件名为venv
    $ py -3.9 -m venv venv
    进入vscode

    win
    $ & e:/code/venv/Scripts/Activate.ps1
    
    • 1
    • 2
    mac
    $ source ./venv/bin/activate
    
    • 1
    • 2

    退出

    $ deactivate
    
    • 1

    $ 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

  • 相关阅读:
    G1D18-Warshall&Floyd&课程报告&matlab下载
    概率论与数理统计学习:随机变量(三)——知识总结与C语言实现案例
    记录--接入微信支付的全套姿势
    如何递归对比两个文件夹当中npy文件的内容
    38 方法区的演进细节
    【Verilog 教程】7.2 Verilog 文件操作
    【Spring Boot】实战:实现Session共享
    操作系统笔记
    【面试篇】地平线深度学习模型算法开发一面
    计讯物联5G RedCap网关TG463化繁为简,推动5G赋能千行百业
  • 原文地址:https://blog.csdn.net/zoeou/article/details/127745470