用wsl自带的python 3.10下载适用于3.12的pandas版本结合uv安装python 3.12模拟离线安装场景

  1. uv安装python 3.12

    root@6ae32a5ffcde:/par/38# cd ..
    root@6ae32a5ffcde:/par# mkdir 312
    root@6ae32a5ffcde:/par# cd 312
    root@6ae32a5ffcde:/par/312# uv python install 3.12
    Installed Python 3.12.13 in 7.55s

    • cpython-3.12.13-linux-x86_64-gnu (python3.12)
      root@6ae32a5ffcde:/par/312# uv venv --python 3.12
      Using CPython 3.12.13
      Creating virtual environment at: .venv
      Activate with: source .venv/bin/activate
      root@6ae32a5ffcde:/par/312#
      exit
  2. 用wsl自带的python 3.10下载适用于3.12的pandas版本

    root@DESKTOP-59T6U68:/mnt/c/d# python3
    Python 3.10.12 (main, Mar 3 2026, 11:56:32) [GCC 11.4.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.

    root@DESKTOP-59T6U68:/mnt/c/d# python3 pip.pyz download pandas -d ./amdlxwhl/312 -i https://mirrors.aliyun.com/pypi/simple/ --platform manylinux_2_28_x86_64 --only-binary=:all: --python-version 3.12 --default-timeout=100
    Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
    Collecting pandas
    Downloading https://mirrors.aliyun.com/pypi/packages/c4/a8/3a61a721472959ab0ce865ef05d10b0d6bfe27ce8801c99f33d4fa996e65/pandas-3.0.2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (10.9 MB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.9/10.9 MB 13.1 MB/s eta 0:00:00
    Collecting numpy>=1.26.0 (from pandas)
    Downloading https://mirrors.aliyun.com/pypi/packages/0a/0d/0e3ecece05b7a7e87ab9fb587855548da437a061326fff64a223b6dcb78a/numpy-2.4.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (16.6 MB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 16.6/16.6 MB 14.1 MB/s eta 0:00:00
    Collecting python-dateutil>=2.8.2 (from pandas)
    Downloading https://mirrors.aliyun.com/pypi/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
    Collecting six>=1.5 (from python-dateutil>=2.8.2->pandas)
    Downloading https://mirrors.aliyun.com/pypi/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl (11 kB)
    Saved ./amdlxwhl/312/pandas-3.0.2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
    Saved ./amdlxwhl/312/numpy-2.4.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
    Saved ./amdlxwhl/312/python_dateutil-2.9.0.post0-py2.py3-none-any.whl
    Saved ./amdlxwhl/312/six-1.17.0-py2.py3-none-any.whl
    Successfully downloaded pandas numpy python-dateutil six
    root@DESKTOP-59T6U68:/mnt/c/d# ls amdlxwhl/312
    numpy-2.4.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
    pandas-3.0.2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
    python_dateutil-2.9.0.post0-py2.py3-none-any.whl
    six-1.17.0-py2.py3-none-any.whl

  3. 返回安装了uv的docker环境

    root@DESKTOP-59T6U68:/mnt/c/d# docker exec -it gcc bash
    root@6ae32a5ffcde:/# uv python list
    cpython-3.15.0a7-linux-x86_64-gnu
    cpython-3.15.0a7+freethreaded-linux-x86_64-gnu
    cpython-3.14.3-linux-x86_64-gnu /root/.local/bin/python3.14 -> /root/.local/share/uv/python/cpython-3.14.3-linux-x86_64-gnu/bin/python3.14
    cpython-3.14.3-linux-x86_64-gnu /root/.local/share/uv/python/cpython-3.14-linux-x86_64-gnu/bin/python3.14
    cpython-3.14.3+freethreaded-linux-x86_64-gnu
    cpython-3.13.12-linux-x86_64-gnu
    cpython-3.13.12+freethreaded-linux-x86_64-gnu
    cpython-3.12.13-linux-x86_64-gnu /root/.local/bin/python3.12 -> /root/.local/share/uv/python/cpython-3.12-linux-x86_64-gnu/bin/python3.12
    cpython-3.12.13-linux-x86_64-gnu /root/.local/share/uv/python/cpython-3.12-linux-x86_64-gnu/bin/python3.12
    cpython-3.11.15-linux-x86_64-gnu
    cpython-3.11.2-linux-x86_64-gnu /usr/bin/python3.11
    cpython-3.11.2-linux-x86_64-gnu /usr/bin/python3 -> python3.11
    cpython-3.10.20-linux-x86_64-gnu
    cpython-3.9.25-linux-x86_64-gnu
    cpython-3.8.20-linux-x86_64-gnu /root/.local/share/uv/python/cpython-3.8-linux-x86_64-gnu/bin/python3.8
    pypy-3.11.15-linux-x86_64-gnu
    pypy-3.10.16-linux-x86_64-gnu
    pypy-3.9.19-linux-x86_64-gnu
    pypy-3.8.16-linux-x86_64-gnu
    graalpy-3.12.0-linux-x86_64-gnu
    graalpy-3.11.0-linux-x86_64-gnu
    graalpy-3.10.0-linux-x86_64-gnu
    graalpy-3.8.5-linux-x86_64-gnu
    root@6ae32a5ffcde:/# cd root/.local/share/uv/python/cpython-3.12-linux-x86_64-gnu/bin/
    root@6ae32a5ffcde:~/.local/share/uv/python/cpython-3.12-linux-x86_64-gnu/bin# ./python3.12 /par/pip.pyz install --no-index -f /par/amdlxwhl/312 pandas
    error: externally-managed-environment

    × This environment is externally managed
    ╰─> This Python installation is managed by uv and should not be modified.

    note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
    hint: See PEP 668 for the detailed specification.

试图在3.12的安装目录下直接安装离线包触发错误,不准备用--break-system-packages强制安装

  1. 返回uv的venv python 3.12环境

    root@6ae32a5ffcde:~/.local/share/uv/python/cpython-3.12-linux-x86_64-gnu/bin# cd
    root@6ae32a5ffcde:~# cd par/312
    bash: cd: par/312: No such file or directory
    root@6ae32a5ffcde:~# cd /par/312
    root@6ae32a5ffcde:/par/312# ls
    root@6ae32a5ffcde:/par/312# source .venv/bin/activate
    (312) root@6ae32a5ffcde:/par/312# python /par/pip.pyz install --no-index -f /par/amdlxwhl/312 pandas
    Looking in links: /par/amdlxwhl/312
    Processing /par/amdlxwhl/312/pandas-3.0.2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
    Processing /par/amdlxwhl/312/numpy-2.4.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (from pandas)
    Processing /par/amdlxwhl/312/python_dateutil-2.9.0.post0-py2.py3-none-any.whl (from pandas)
    Processing /par/amdlxwhl/312/six-1.17.0-py2.py3-none-any.whl (from python-dateutil>=2.8.2->pandas)
    Installing collected packages: six, numpy, python-dateutil, pandas
    Successfully installed numpy-2.4.4 pandas-3.0.2 python-dateutil-2.9.0.post0 six-1.17.0
    (312) root@6ae32a5ffcde:/par/312# python /par/pip.pyz list installed
    Package Version


    numpy 2.4.4
    pandas 3.0.2
    python-dateutil 2.9.0.post0
    six 1.17.0
    (312) root@6ae32a5ffcde:/par/312# uv pip list
    Package Version


    numpy 2.4.4
    pandas 3.0.2
    python-dateutil 2.9.0.post0
    six 1.17.0
    (312) root@6ae32a5ffcde:/par/312# python
    Python 3.12.13 (main, Mar 24 2026, 22:49:22) [Clang 22.1.1 ] on linux
    Type "help", "copyright", "credits" or "license" for more information.

    import pandas

虽然用了自己的/par/pip.pyz脚本安装pandas,uv也能识别到,import pandas也成功了。就是安装过程比uv安装慢。

相关推荐
TechWayfarer23 分钟前
IP精准定位服务在快递网点规划中的应用:如何用客户位置数据辅助选址
大数据·网络·python·tcp/ip·交通物流
CSND74036 分钟前
零基础学Python合集---3:字符串的定义和常用方法
人工智能·python
五月君_1 小时前
放弃 Python,Kimi 用 TS + Node.js 重写了一个 Kimi Code
开发语言·python·node.js
还是鼠鼠1 小时前
AI掘金头条新闻系统 (Toutiao News)-获取用户信息
后端·python·mysql·fastapi·web
Cloud_Shy6181 小时前
解读《Effective Python 3rd Edition》:从练气到老魔
开发语言·python
SunnyDays10111 小时前
Python 操作 Excel 超链接:添加网页、文件、工作表和图片链接
python·excel
li星野1 小时前
RAG优化系列:HyDE(假设文档嵌入)——让LLM先写答案再检索
python·学习
知识分享小能手1 小时前
Flask入门学习教程,从入门到精通,Flask智能租房——用户中心知识点详解(9)
python·学习·flask
MageGojo1 小时前
做节日活动页时,如何用 API 快速生成对联内容
javascript·python·节日·对联生成
l1t1 小时前
DeepSeek总结的使用实体-组件-系统和基于存在性处理进行Python编程15-17
开发语言·数据库·python