Colab cannot find an installed a package - pip

I'm trying to install a package called fenics in Google Colab.
I tried both:
!pip install fenics
>> fenics in /usr/local/lib/python3.6/dist-packages (2019.1.0)
and
!apt-get install fenics
Then a simple import fenics raises ModuleNotFoundError. Restarting the runtime doesn't solve the problem. Any clues?

Following the instruction
!apt-get install software-properties-common
!add-apt-repository ppa:fenics-packages/fenics
!apt-get update
!apt-get install --no-install-recommends fenics
Then you can import fenics. Here's the notebook I tested.

Related

unable to load torchaudio even after installing

I'm trying to use torchaudio but I'm unable to import it. I have installed it and it is also visible through the pip list.
<ipython-input-6-4cf0a64f61c0> in <module>
----> 1 import torchaudio
ModuleNotFoundError: No module named 'torchaudio'
pytorch-lightning 1.2.0
torch 1.10.1
torchaudio 0.10.1
torchvision 0.11.2
WARNING: You are using pip version 21.1.2; however, version 21.3.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
Since you are using linux and CPU, you should consider uninstalling every pytorch related packages and re-install them via:
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu
as shown here.
I was stuck with the same error. Tried a lot of ways to install and use torchaudio.
This was worked for me (after uninstalling existing torchaudio):
import os
!git clone https://github.com/pytorch/audio.git
os.chdir("audio")
!git checkout 632ea67
!python setup.py install

How to install numpy on linux subsystem for windows?

I'm trying to install NumPy on the Linux subsystem for Windows, but it when I try to install pip sudo apt install python-pip so that I can use pip install numpy, it gives the error E: Unable to locate package python-pip.
Any suggestions?
Thanks
Edit:
When I run pip install numpy it gives the error: Command 'pip' not found, but there are 18 similar ones.
My recollection is also that python did not come installed with ubuntu, but I could be remembering incorrectly.
Try this sudo apt install python3-pip

How to Install Zipline on Google Colab

!apt-get install libatlas-base-dev python-dev gfortran pkg-config libfreetype6-dev hdf5-tools
!pip install zipline
!pip install zipline ingest
!pip uninstall pandas
!pip install --upgrade pandas==0.23.0
%load_ext zipline
I have following issue:
ValueError: index must be monotonic increasing or decreasing
after adding cuperto suggested (!pip install pandas==0.22.0),
I got this error:
enter image description here
any suggestion?
Trying to run Zipline on Google Colab, I ran into the exact same problem.
I believe the problem comes from the fact that zipline 1.4.1 has requirement pandas<=0.22,>=0.18.1
So I installed an older version of pandas and it worked:
!pip install pandas==0.22.0

Geopandas in Google Colab

I am using Google Colab. I have installed the PyGMT. Now, I want to install the Geopandas but I got lots of errors when i type "!pip install geopandas" or "!conda install geopandas". Can you help me to install geopandas in googlecolab?
Here is my code;
from google.colab import drive
drive.mount('/content/drive')
import os
import sys
import os
sys.path.append('/usr/local/lib/python3.8/site-packages')
os.environ["GMT_LIBRARY_PATH"]="/usr/local/lib"
!wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
!chmod +x Miniconda3-latest-Linux-x86_64.sh
!bash ./Miniconda3-latest-Linux-x86_64.sh -bfp /usr/local
!conda update conda -y -q
!conda config --prepend channels conda-forge
!conda install -q -y --prefix /usr/local python=3.8 pygmt
import sys
import os
sys.path.append('/usr/local/lib/python3.8/site-packages')
os.environ["GMT_LIBRARY_PATH"]="/usr/local/lib"
!pip install geopandas
import pygmt
import pandas as pd
import geopandas
When I do !pip install geopandas and import it, it says that: ModuleNotFoundError: No module named 'pyproj._network'
have you tried using
!pip install --upgrade geopandas
don't forget to also update the other dependencies
!pip install --upgrade pyshp
!pip install --upgrade shapely
!pip install --upgrade descartes
Found it in this Google Colab tutorial, https://colab.research.google.com/drive/1We-LMiSeucESsiB1tmvL9nZrntyWsri-#scrollTo=xIXl9KBOxVKE
Hope it works,
Conda is not available in google colab by default like numpy, pandas etc is. So doing !conda install geopandas won't do any help. There's another way around it though. You CAN install conda on google colab and using it you can install other packages. Here's how:
!pip install -q condacolab
import condacolab
condacolab.install()
Then try installing with !conda install geopandas and import it using import geopandas
You can use these three lines to import geopandas in colab:
!apt install libspatialindex-dev
!pip install rtree
!pip install geopandas

Installing faiss on Google Colaboratory

I try to follow instruction on the MUSE project.
They require PyTorch and Faiss. PyTorch is easy to install. But I found problem with installing Faiss.
The instruction on MUSE tell me to use
conda install faiss-cpu -c pytorch
But Google Colab doesn't support conda (When I tried !pip install conda, it didn't work)
And Faiss didn't work when I !pip install faiss either.
Is there a way to install Faiss or conda?
Here's how I eventually install faiss.
!wget https://anaconda.org/pytorch/faiss-cpu/1.2.1/download/linux-64/faiss-cpu-1.2.1-py36_cuda9.0.176_1.tar.bz2
!tar xvjf faiss-cpu-1.2.1-py36_cuda9.0.176_1.tar.bz2
!cp -r lib/python3.6/site-packages/* /usr/local/lib/python3.6/dist-packages/
!pip install mkl
Then, I can import faiss with no problem. The warning is that I didn't use GPU. If you want to use GPU, you need to install this instead:
https://anaconda.org/pytorch/faiss-gpu/1.2.1/download/linux-64/faiss-gpu-1.2.1-py36_cuda9.0.176_1.tar.bz2
Update June 2020
As #Kuffner said, you can now use !pip to install it. (I test and simplify it a bit)
For CPU
!apt install libomp-dev
!pip install faiss
For GPU
!pip install faiss-gpu
As of June 2020 the easiest solution for Colab GPU runtime is:
!apt install libomp-dev
!python -m pip install --upgrade faiss faiss-gpu
import faiss
The code comes from here: faiss/issues/890
Try this solution, it should work!
!pip install faiss-cpu --no-cache
Try this way!
install conda
!wget -c -O anaconda.sh 'https://repo.continuum.io/archive/Anaconda3-5.1.0-Linux-x86_64.sh'
!bash anaconda.sh -b
!cd /usr/bin/ && ln -sf /content/anaconda3/bin/conda conda
!cd /content/
install faiss
!yes y | conda install faiss-gpu -c pytorch

Resources