如何在 google colab notebook 上执行 '!pip install tr​​ee' 后使 '!tree' 工作?

Kev*_*Yin 3 python tree google-colaboratory

!pip install tree在 google colab notebook 上做过。它表明Pillow in /usr/local/lib/python3.6/dist-packages (from tree) (4.3.0). 但是当我使用!tree. 笔记本提醒了我bin/bash: tree: command not found。如何解决?

我尝试了几次,但都失败了。

这显示了:

Collecting tree
  Downloading https://files.pythonhosted.org/packages/29/3f/63cbed2909786f0e5ac30a4ae5791ad597c6b5fec7167e161c55bba511ce/Tree-0.2.4.tar.gz
Requirement already satisfied: Pillow in /usr/local/lib/python3.6/dist-packages (from tree) (4.3.0)
Collecting svgwrite (from tree)
  Downloading https://files.pythonhosted.org/packages/87/ce/3259f75aebb12d8c7dd9e8c479ad4968db5ed18e03f24ee4f6be9d9aed23/svgwrite-1.2.1-py2.py3-none-any.whl (66kB)
     |????????????????????????????????| 71kB 23.9MB/s 
Requirement already satisfied: setuptools in /usr/local/lib/python3.6/dist-packages (from tree) (41.0.1)
Requirement already satisfied: click in /usr/local/lib/python3.6/dist-packages (from tree) (7.0)
Requirement already satisfied: olefile in /usr/local/lib/python3.6/dist-packages (from Pillow->tree) (0.46)
Requirement already satisfied: pyparsing>=2.0.1 in /usr/local/lib/python3.6/dist-packages (from svgwrite->tree) (2.4.0)
Building wheels for collected packages: tree
  Building wheel for tree (setup.py) ... done
  Stored in directory: /root/.cache/pip/wheels/c7/08/aa/42261411808c634cd1d0e9fe6cde5e78bf47c2c8028f3930af
Successfully built tree
Installing collected packages: svgwrite, tree
Successfully installed svgwrite-1.2.1 tree-0.2.4

!pip install tree
!tree
Run Code Online (Sandbox Code Playgroud)

我希望它显示目录中文件的结构。

小智 6

您似乎将 pip 与本地包管理器混淆了?

!apt-get install tree 做你想做的事:

.
??? sample_data
    ??? anscombe.json
    ??? california_housing_test.csv
    ??? california_housing_train.csv
    ??? mnist_test.csv
    ??? mnist_train_small.csv
    ??? README.md

1 directory, 6 files
Run Code Online (Sandbox Code Playgroud)