Jupyter 无法下载文件夹如何实现曲线救国
作者:caesarhtx 时间:2023-01-12 10:28:52
原问题:
https://stackoverflow.com/questions/48122744/how-to-download-all-files-and-folder-hierarchy-from-jupyter-notebook/48141707
解决方法是:
1. 找到你想下载的文件夹
2. 打开文件夹,新建一个ipynb
3. 粘贴下面代码并运行
4. 回到文件夹,刷新,看到多了个archive.tar的压缩文件,下载这个文件解压就行。
import os
import tarfile
def recursive_files(dir_name='.', ignore=None):
for dir_name,subdirs,files in os.walk(dir_name):
if ignore and os.path.basename(dir_name) in ignore:
continue
for file_name in files:
if ignore and file_name in ignore:
continue
yield os.path.join(dir_name, file_name)
def make_tar_file(dir_name='.', tar_file_name='tarfile.tar', ignore=None):
tar = tarfile.open(tar_file_name, 'w')
for file_name in recursive_files(dir_name, ignore):
tar.add(file_name)
tar.close()
dir_name = '.'
tar_file_name = 'archive.tar'
ignore = {'.ipynb_checkpoints', '__pycache__', tar_file_name}
make_tar_file(dir_name, tar_file_name, ignore)
补充 知识:Jupyter安装拓展nbextensions及解决官网下载慢的问题
Anaconda Jupyter安装拓展nbextensions
先在终端pip两个包:
Pip install jupyter_contrib_nbextensions
Pip install jupyter_nbextensions_configurator
安装成功后
Jupyter contrib nbextension install --user
Pip install jupyter_contrib_nbextensions
Pip install jupyter_nbextensions_configurator
Jupyter contrib nbextension install --user
使用豆瓣镜像:
但是直接这样pip下载很慢,简直慢到怀疑人生,下载了半天还下载失败了/(ㄒoㄒ)//(ㄒoㄒ)/
所以我们可以使用豆瓣镜像,即在后面加 -i https://pypi.douban.com/simple
这个堪称神器呀,下载的时候刷刷的O(∩_∩)O
Pip install jupyter_contrib_nbextensions -i https://pypi.douban.com/simple
Pip install jupyter_nbextensions_configurator -i https://pypi.douban.com/simple
后面操作不变:
Jupyter contrib nbextension install --user
Pip install jupyter_contrib_nbextensions -i https://pypi.douban.com/simple
Pip install jupyter_nbextensions_configurator -i https://pypi.douban.com/simple
Jupyter contrib nbextension install --user
最后再打开jupyter
jupyter notebook
操作成功后重启jupyter 如下图所示,增加了Nbextensions一栏
但是刚进去时是灰色的,取消勾选红色圈圈中的勾选项即可
拓展安装完成,现在就可以添加一些常用的插件了(●'◡'●)
来源:https://blog.csdn.net/caesarhtx/article/details/93050946
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
go使用consul实现服务发现及配置共享实现详解
![](https://img.aspxhome.com/file/2023/0/134320_0s.png)
如何用Python搭建gRPC服务
![](https://img.aspxhome.com/file/2023/3/92333_0s.png)
使用Python给头像戴上圣诞帽的图像操作过程解析
![](https://img.aspxhome.com/file/2023/4/92304_0s.jpg)
Python循环语句之break与continue的用法
![](https://img.aspxhome.com/file/2023/0/115660_0s.jpg)
SQL常用数据库操作命令使用方法
opencv-python 读取图像并转换颜色空间实例
深入了解Vue3中props的原理与使用
详解thinkphp+redis+队列的实现代码
![](https://img.aspxhome.com/file/2023/6/125776_0s.png)
Mysql 执行一条语句的整个过程详细
![](https://img.aspxhome.com/file/2023/5/121545_0s.png)
python编程实现希尔排序
![](https://img.aspxhome.com/file/2023/3/102763_0s.jpg)
记录模型训练时loss值的变化情况
![](https://img.aspxhome.com/file/2023/9/105249_0s.jpg)
详解Git 的 rebase 命令使用方法
![](https://img.aspxhome.com/file/2023/0/123730_0s.jpg)
Vue前端表格导出Excel文件的图文教程
![](https://img.aspxhome.com/file/2023/7/139847_0s.png)