如果笔记本在Google Colab和其他任何地方运行,是否可以有条件地安装python软件包?
例如,如果您有一个需要一些python软件包的笔记本,但只希望在colab中运行笔记本时!pip install mypackage
,是否可以通过某种方法进行测试?例如
if current_environment == 'Google Colab':
!pip install my_packages
答案 0 :(得分:1)
I found the answer here。您可以查找colabtools文件夹。
import pandas as pd
import numpy as np
import networkx as nx
from bokeh.io import show, output_file
from bokeh.models import Plot, Range1d, MultiLine, Circle, HoverTool, TapTool, BoxEditTool, BoxSelectTool, BoxZoomTool, ResetTool, PanTool, WheelZoomTool, ZoomInTool, ZoomOutTool, SaveTool, UndoTool, PointDrawTool
from bokeh.models.graphs import from_networkx, NodesAndLinkedEdges, EdgesAndLinkedNodes
from bokeh.palettes import Spectral4
import warnings
import matplotlib.pyplot as plt
%matplotlib notebook
from IPython.display import display, HTML
from IPython.core.interactiveshell import InteractiveShell