How do I install Python packages in Google's Colab?
imagine yoiu want to install two different packages into your collab-account:
so you are wanting to create a setup to install these two packages in the Google's Colab;
idea: You can use !setup.py install to do that.
we can say: Colab is just like a Jupyter notebook.
Therefore, we can use the ! operator here to install literally any package in Colab.
What it actually does is, it tells the notebook cell that this line is not a Python code, its a command line script. So, to run any command line script in Colab, just add a ! preceding the line.
let us say for example: !pip install panda.
This will treat that line (here pip install panda) as a command prompt line and not some Python code.
but be carefully: if you do this without adding the ! preceding the line, it'll throw up an error saying "invalid syntax"
nowadays we can do this with a even simpler approach: just use the !pip magic, like:
!pip install scipy
explanation: That little code snippet will automatically use the correct Python version.
that said: using pip is allways a good choice: but be aware: using !pip might be tied to a different version of Python,
Top comments (0)