首页 > 解决方案 > 使用google colab将其安装在谷歌驱动器中后无法在pip中找到模块

问题描述

我尝试在谷歌驱动器中安装一个模块,这样我就可以将它永久保存在谷歌 colab 中,甚至重新启动会话。这是我的代码:

# 1. create link to google drive
import os, sys
shortcut = '/content/lib'                            
source   = '/content/drive/MyDrive/Colab Libraries'    
os.symlink(source, shortcut)                        
sys.path.insert(0, shortcut)          

# 2. install it
!pip install --target=$shortcut playsound

# 3. try importing it
import playsound      # working ok

# 4. find it in the module list
!pip list             # cant find playsound

# 5. find it by pip show
!pip show playsound   # can't find it as well

playsound尽管我成功导入了它,但我在 #4 和 #5 中找不到它。我的问题是:

  1. 我怎样才能将它包含在pip listpip show
  2. 以及如何卸载它?不能这样做,pip uninstall playsound因为它说它找不到模块。

标签: pythonpipgoogle-colaboratory

解决方案


推荐阅读