python包管理rye安装torch

最近在使用pip或中poetry对python进行包管理,始终觉得不是很理想。2023年flask的作者参考rust的管理哲学,编写了rye的python包管理工具,故试用之。使用过程中,遇到安装torch的问题,故这里写一下笔记。

1. 本地windows安装torch(国内更推荐)

到官网找到自己需要的torch版本进行下载:
https://download.pytorch.org/whl/torch/
直接下载:
https://download.pytorch.org/whl/cu121/torch-2.1.0%2Bcu121-cp310-cp310-win_amd64.whl
这里下载到G:/download/python_whl目录后w使用rye相关指令。

rye add "torch" --path "G:\download\pyton_whl\torch-2.1.0+cu121-cp310-cp310-win_amd64.whl"
rye sync --verbose

2. 网络安装torch(国内容易超时)

配置源,修改pyproject.toml文件

[[tool.rye.sources]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu121"

安装指定版本的torch

rye add "torch==2.1.0+cu121"
rye sync --verbose

3.指定版本的python安装(解决无法下载的问题)

rye toolchain fetch 3.10.11

安装时,由于是地址是指定到github下载,经常无法下载,解决方法:

  • 手动到报错提示的网址,使用浏览器进行下载
  • 下载后,解压到 C:/Users/[你的用户名]/.rye/py目录,解压目录名称,示例:cpython@3.10.11
    在这里插入图片描述
  • 目录内容:
    在这里插入图片描述
  • 8
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用CSV文件保存数据是一种简单而有效的方法,以下是一些实现Python图书管理系统使用CSV文件保存数据的步骤: 1. 导入csv模块:在Python中使用csv模块,需要先导入它。 ```python import csv ``` 2. 创建CSV文件:使用csv.writer()函数创建一个CSV文件,并将图书信息写入文件中。 ```python with open('books.csv', mode='w', newline='') as file: writer = csv.writer(file) writer.writerow(['Book Title', 'Author', 'Publisher', 'ISBN', 'Status']) writer.writerow(['The Alchemist', 'Paulo Coelho', 'HarperCollins', '9780061122415', 'Available']) writer.writerow(['The Catcher in the Rye', 'J.D. Salinger', 'Little, Brown and Company', '9780316769488', 'Checked Out']) ``` 3. 读取CSV文件:使用csv.reader()函数读取CSV文件中的图书信息。 ```python with open('books.csv', mode='r') as file: reader = csv.reader(file) for row in reader: print(row) ``` 4. 更新CSV文件:使用csv.writer()函数更新CSV文件中的图书信息。 ```python with open('books.csv', mode='w', newline='') as file: writer = csv.writer(file) writer.writerow(['Book Title', 'Author', 'Publisher', 'ISBN', 'Status']) writer.writerow(['The Alchemist', 'Paulo Coelho', 'HarperCollins', '9780061122415', 'Available']) writer.writerow(['The Catcher in the Rye', 'J.D. Salinger', 'Little, Brown and Company', '9780316769488', 'Checked Out']) # Update the status of 'The Catcher in the Rye' writer.writerow(['The Catcher in the Rye', 'J.D. Salinger', 'Little, Brown and Company', '9780316769488', 'Available']) ``` 以上是一些实现Python图书管理系统使用CSV文件保存数据的步骤,你可以根据自己的需求进行修改和扩展。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值