Geopandas in Google Colab - geopandas

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

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

Colab cannot find an installed a package

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.

Can't importe scikit-image in python 3.7

I have successfully installed the package scikit-image in my python project. However, I can't seem to import it to my python code. It seems it has a problem with the hyphen in the package. I have tried to install skimage, but it pip does not want to install this package and suggest I should install scikit-image instead. Does anyone know how I can solve this problem?
To install:
pip install scikit-image
To check which version is installed:
pip show scikit-image
To use in Python:
import skimage
or, something more specific:
from skimage.morphology import skeletonize
If that doesn't work, run each of the following commands and paste the output into your question:
which pip
pip -V
which python
python -V

Import Tensorflow in spyder on mac

I followed the instructions on tensorflow.org:
./conda create -n tensorflow python=2.7
source activate tensorflow
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/tensorflow-0.9.0-py2-none-any.whl --ignore-installed
pip install --upgrade $TF_BINARY_URL
When I run python in terminal, I can import tensorflow
But when I try to import tensorflow in Spyder, I got:
ImportError: No module named tensorflow
How to get tensorflow in Spyder?
I just found out that if environment is changed at the Launcher from root to tensorflow, I can install a fresh copy of Spyder in that environment. Once installed, import tensorflow works.

Python pip not working for scipy, scikit-learn and gensim

I'm trying to install scipy, scikit-learn, and gensim on Windows 7 with Python 3.3.
If I try any of these:
pip install sci
pip install scipy
pip install scikit-learn
pip install gensim
I end up with an ImportError similar to:
ImportError: no module named numpy
And yes, I have installed numpy - it works fine if I try to import it in Python. I've managed to install scipy and scikit-learn by downloading executable installers, but gensim doesn't have one...
I've also tried using easy_install for all three, but that doesn't work either.
Is it something to do with the Python installation? Any ideas? Thanks a lot in advance!

Resources