Cannot import geopandas even though it is installed in environment

  anaconda, geopandas, python-3.x, qgis

In have this behavior that I cannot really understand. Some background might be in place. I earlier created an environment called geo in which I installed geopandas. I worked like a charm, but I later realized that I wanted to split POLYGON-type objects into smaller ones.

Reading a little, I found out that QGIS has something that might help. So, following this really helpful answer (https://stackoverflow.com/a/67447061/5363686), I created a conda-qgis environment to be able to

from qgis.core import *

and it worked like a charm. I also install geopandas in that environment, as can be seen below it is there:

# packages in environment at C:Userss-degossondevarennesAnaconda3envsconda-qgis:
#
# Name                    Version                   Build  Channel
attrs                     21.2.0             pyhd8ed1ab_0    conda-forge
boost-cpp                 1.74.0               h54f0996_3    conda-forge
brotlipy                  0.7.0           py39hb82d6ee_1001    conda-forge
bzip2                     1.0.8                h8ffe710_4    conda-forge
ca-certificates           2021.5.30            h5b45459_0    conda-forge
cairo                     1.16.0            hb19e0ff_1008    conda-forge
certifi                   2021.5.30        py39hcbf5309_0    conda-forge
cffi                      1.14.5           py39h0878f49_0    conda-forge
cfitsio                   3.470                h0af3d06_7    conda-forge
chardet                   4.0.0            py39hcbf5309_1    conda-forge
click                     7.1.2              pyh9f0ad1d_0    conda-forge
click-plugins             1.1.1                      py_0    conda-forge
cligj                     0.7.2              pyhd8ed1ab_0    conda-forge
coverage                  5.5              py39hb82d6ee_0    conda-forge
cryptography              3.4.7            py39hd8d06c1_0    conda-forge
curl                      7.77.0               h789b8ee_0    conda-forge
cycler                    0.10.0                     py_2    conda-forge
decorator                 5.0.9              pyhd8ed1ab_0    conda-forge
exiv2                     0.27.1               hfa2c1cf_0    conda-forge
expat                     2.4.1                h39d44d4_0    conda-forge
fiona                     1.8.20           py39h9f1b043_0    conda-forge
fontconfig                2.13.1            h1989441_1005    conda-forge
freetype                  2.10.4               h546665d_1    conda-forge
freexl                    1.0.6                ha8e266a_0    conda-forge
future                    0.18.2           py39hcbf5309_3    conda-forge
gdal                      3.2.2            py39h6795fcd_5    conda-forge
geopandas                 0.9.0              pyhd8ed1ab_1    conda-forge
geopandas-base            0.9.0              pyhd8ed1ab_1    conda-forge
geos                      3.9.1                h39d44d4_2    conda-forge
geotiff                   1.6.0                h8e90983_5    conda-forge
gettext                   0.19.8.1          h1a89ca6_1005    conda-forge

BUT, I cannot import it

from flatten_json import flatten
import requests
import flatten_json
import pandas as pd
import os, json
import numpy as np
import glob
import pathlib
import matplotlib.pyplot as plt
import geopandas
from qgis.core import *
#import qgis-plutil
from pandas.io.json import json_normalize
from operator import attrgetter

from shapely.geometry import Point, Polygon
import geopandas as gpd


from fetch_api_data import get_floor_boundary_data, get_obstacle_data,get_xy_data, jsonNormalize
from store_function import flatten_nested_json_df, get_items

np.seterr(divide='ignore', invalid='ignore')
pd.set_option('display.max_columns', None)

from IPython.display import Markdown as md

from shapely.geometry import box, Polygon, MultiPolygon, GeometryCollection

returns:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-5cd75bf81655> in <module>
      8 import pathlib
      9 import matplotlib.pyplot as plt
---> 10 import geopandas
     11 from qgis.core import *
     12 #import qgis-plutil

ModuleNotFoundError: No module named 'geopandas'

This, is rather strange. And yes, I open my notebook in the right environement.

Does anyone spot my mistake?

Thankful for any help!

Source: Python-3x Questions

LEAVE A COMMENT