geopandas read_file function causes ImportError - python

I just got a new computer and after downloading the newest version of the anaconda distribution I tried to install geopandas and run my script.
However, the gpd.read_file command causes an ImportError.
I have been trying to reinstall everything but nothing changed.
Does anybody know how to figure this out?
import geopandas as gpd
path = "C:/someshapefile.shp"
gpd.read_file(path)
ImportError: The 'read_file' function requires the 'pyogrio' or
'fiona' package, but neither is installed or imports correctly.
Importing fiona resulted in:
DLL load failed while importing ogrext: The specified module could not be found.
Importing pyogrio resulted in:
No module named 'pyogrio'
Just installing fiona manually like this:
conda install -c conda-forge fiona
did unfortunately not work for me.
Thanks a lot!
CM

git issue comment
python -m pip install git+https://github.com/Toblerity/Fiona.git
working for me

Related

Implement solution to get stable gdal and fiona library versions on Windows

I am trying to read a shapefile using python's geopandas in vscode. I successfully installed geopandas using conda, but when I use gpd.read_file, I get the following error output:
ImportError: the 'read_file' function requires the 'fiona' package, but it is not installed or does not import correctly.
Importing fiona resulted in: DLL load failed while importing ogrext: The specified module could not be founds
I am trying to follow the following solution: ImportError: the 'read_file' function requires the 'fiona' package, but it is not installed or does not import correctly. Importing fiona resulted in:
Apparently, I was using below versions of GDAL and fiona combinations which didn't work for me.
GDAL-3.3.2-cp38-cp38-win_amd64.whl
Fiona-1.8.20-cp38-cp38-win_amd64.whl
I had to uninstall the above versions and install the below versions instead. This resolved the issue.
GDAL-3.2.3-cp38-cp38-win_amd64.whl
Fiona‑1.8.19‑cp38‑cp38‑win_amd64.whl
Should I uninstall gdal and fiona using pip uninstall gdal fiona and then use pip install <version> to install the working versions? Also, since the post is from Oct 2021, should I still use the mentioned versions?

import geopandas successfully, but raise issue with fiona(import error)

I am Windows and using python through jupyternotebook.
python 3.9.7, windows 64 bit,
I want to import geopandas, so I used the code conda install --channel conda-forge geopandas. It seemed work at first because I could successfully import geopandas without error, but when I want to run the following code, an import error appears.
world = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres"))
world.columns
ImportError: the 'read_file' function requires the 'fiona' package, but it is not installed or does not import correctly.
Importing fiona resulted in: DLL load failed while importing ogrext
I saw other people asked the same questions, but none of their solutions worked. At first, I saw someone said nstalling geopandas by condas might installed wrong version of fiona and gdal. So I tried to update by conda update conda, and conda update -n base conda-package-handling and conda update --all. However, these code didn't work. Later, I directly installed the .whl file from python library: Fiona-1.8.20-cp39-cp39-win_amd64.whl and GDAL-3.4.1-cp39-cp39-win_amd64.whl, and use pip to install them. But the error still appeared.
I really have no idea how to deal with such issue, is it because the version of fiona and gdal was not consistent? Please give me some suggestions, thanks ahead!
I have solved this problem by creating a new environment followed this article: https://medium.com/analytics-vidhya/fastest-way-to-install-geopandas-in-jupyter-notebook-on-windows-8f734e11fa2b
This is the fast way to solve this problem.

GeoPandas not getting imported

I am trying to import the GeoPandas module (which I had recently installed on my laptop) in a Jupyter notebook but it returning this error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-a62d01c1d62e> in <module>
----> 1 import geopandas as gpd
ModuleNotFoundError: No module named 'geopandas'
I am certain that geopandas installed correctly. Can someone please suggest a fix?
It may not be installed in the right kernel for your jupyter notebook. One way to fix this is to run %pip install geopandas in a cell in your notebook. Then you can restart the kernel and you should be able to import it.
edit
just tried this out again and I had to add a --user to the magic command. The final command should look like %pip install geopandas --user
For me, I had to manually install the libraries as i could not import them although they were present in pip list of installed packages.
I went to https://www.lfd.uci.edu/~gohlke/pythonlibs/, where I downloaded the compatible version for GDAL, Pyproj, Fiona, Shapely and Geopandas.
Then I manually installed them using:
pip install the file path

Shapely import error: No module named 'shapely'

I've installed shapely with pip install shapely and importing it as from shapely.geometry import Point. I get this error:
from shapely.geometry import Point
ModuleNotFoundError: No module named 'shapely'
I'm n MacOS High Sierra. All other installed python libraries work like a charm. I'm new to Python so forgive me in advance.
I've read several similar questions (like this one) but none seemed to solve my problem.
Run the following command in activated virtualenv:
pip install shapely
I tried this command and it was efficient.
conda install -c conda-forge shapely

Importing universe

I am trying to use OpenAI and I got a import error about universe on Jupyter notebook :
import gym
import universe
No module named 'universe'
When it comes to working on terminal, it returns this error
No module named 'twisted.internet'
Then I also had install twisted with pip, I got this next error :
No module named 'ujson'
and after install ujson, I got a error No module named 'go_vncdriver' again.
I think that I will get other error again.
So which way to install is most convenient ?
Could I install all packages at once ?
préferably, using pip install.
I am using OSX and python3.6.
Try installing,
pip install go_vncdriver
And check again.

Categories