使用uv安装python任意版本的命令详解(uv python install)
使用uv安装python任意版本
先使用uv看看可以装哪些版本
输出:
uv python list cpython-3.14.0a5+freethreaded-linux-x86_64-gnu <download available> cpython-3.14.0a5-linux-x86_64-gnu <download available> cpython-3.13.2+freethreaded-linux-x86_64-gnu <download available> cpython-3.13.2-linux-x86_64-gnu <download available> cpython-3.12.9-linux-x86_64-gnu py312/bin/python3.12 cpython-3.12.9-linux-x86_64-gnu py312/bin/python3 -> python3.12 cpython-3.12.9-linux-x86_64-gnu py312/bin/python -> python3.12 cpython-3.12.9-linux-x86_64-gnu <download available> cpython-3.11.11-linux-x86_64-gnu <download available> cpython-3.10.16-linux-x86_64-gnu <download available> cpython-3.10.12-linux-x86_64-gnu /usr/bin/python3.10 cpython-3.10.12-linux-x86_64-gnu /usr/bin/python3 -> python3.10 cpython-3.10.12-linux-x86_64-gnu /bin/python3.10 cpython-3.10.12-linux-x86_64-gnu /bin/python3 -> python3.10 cpython-3.9.21-linux-x86_64-gnu <download available> cpython-3.8.20-linux-x86_64-gnu <download available> cpython-3.7.9-linux-x86_64-gnu <download available> pypy-3.11.11-linux-x86_64-gnu <download available> pypy-3.10.19-linux-x86_64-gnu <download available> pypy-3.9.19-linux-x86_64-gnu <download available> pypy-3.8.16-linux-x86_64-gnu <download available> pypy-3.7.13-linux-x86_64-gnu <download available>
安装python3.9版本
uv python install 3.9
速度有点慢...安装完成,用uv python list来看一下:
cpython-3.9.21-linux-x86_64-gnu /home/skywalk/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/bin/python3.9
临时添加到路径
# 临时添加路径(关闭终端后失效) export PATH="$HOME/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/bin:$PATH" # 验证 python --version #
好的,证明现在就是python3.9了:
python --version # Python 3.9.21
永久添加到 PATH
- 步骤:编辑
~/.bashrc、~/.zshrc或~/.bash_profile: echo 'export PATH="$HOME/.local/share/uv/python/3.10.12/bin:$PATH"' >> ~/.bashrc
执行
source ~/.bashrc生效
不行,换方法
创建python3.9虚拟环境
uv venv py39 source py39/bin/activate
还是不行
现在只能用这个方法,加参数:--break-system-packages
pip install pip -U --break-system-packages
测试的时候这样用
安装测试库
pip install -e ".[testing]" --break-system-packages
测试
pytest
调试
pip install的时候报错This Python installation is managed by uv and should not be modified.
pip install -e ".[testing]" [notice] A new release of pip is available: 24.3.1 -> 25.1.1 [notice] To update, run: pip install --upgrade pip 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.
搞不定,只好创建虚拟环境
uv venv py39 source py39/bin/activate
uv venv py39 Using CPython 3.9.21 Creating virtual environment at: py39 Activate with: source py39/bin/activate (base) skywalk@ubuntu22win:~$ source py39/bin/activate
总结
到此这篇关于使用uv安装python任意版本命令的文章就介绍到这了,更多相关uv安装python任意版本命令内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
Python实用技巧之列表、字典、集合中根据条件筛选数据详解
这篇文章主要给大家介绍了关于Python技巧之在列表、字典、集合中根据条件筛选数据的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面来一起看看吧2018-07-07
Python Numpy数组扩展repeat和tile使用实例解析
这篇文章主要介绍了Python Numpy数组扩展repeat和tile使用实例解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下2019-12-12
安装python-docx后,无法在pycharm中导入的解决方案
这篇文章主要介绍了安装python-docx后,无法在pycharm中导入的解决方案,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2021-03-03
python爬虫开发之selenium模块详细使用方法与实例全解
这篇文章主要介绍了python爬虫开发之selenium模块详细使用方法与实例全解,selenium模块详细在爬虫开发中主要用来解决JavaScript渲染问题需要的朋友可以参考下2020-03-03
基于spring boot 日志(logback)报错的解决方式
今天小编就为大家分享一篇基于spring boot 日志(logback)报错的解决方式,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2020-02-02


最新评论