pip install geopandas on windows - python

I am relatively new to python and trying to install geopandas on python 3.7 using pip. For separate reasons, I would like to avoid using the anaconda distribution. Following this post, I was able to successfully install geopandas by first installing the dependencies manually. The problem is that now I run into a problem when I try to import geopandas:
import geopandas
The subsequent error message is:
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\geopandas\__init__.py", line 5, in <module>
from geopandas.io.file import read_file
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\geopandas\io\file.py", line 4, in <module>
import fiona
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\fiona\__init__.py", line 87, in <module>
from fiona.collection import BytesCollection, Collection
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\fiona\collection.py", line 9, in <module>
from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
ImportError: DLL load failed: The specified module could not be found.
Any advice would be greatly appreciated

My case is similar to yours. And here is how I got mine setup:
Platform: Windows 10, 64-bit Python Version: Python 3.7
Dependencies (whl files needed):
GDAL‑3.0.4‑cp37‑cp37m‑win_amd64.whl
Fiona‑1.8.13‑cp37‑cp37m‑win_amd64.whl
pyproj‑2.6.0‑cp37‑cp37m‑win_amd64.whl
Rtree‑0.9.4‑cp37‑cp37m‑win_amd64.whl
Steps:
Download the files that match the platform and Python version from
https://www.lfd.uci.edu/~gohlke/pythonlibs/
Install packages (stick with the order)
a) C:\Users...\Python37\Scripts>pip3.7 install C:...\GDAL‑3.0.4‑cp37‑cp37m‑win_amd64.whl
b) C:\Users...\Python37\Scripts>pip3.7 install C:...\Fiona‑1.8.13‑cp37‑cp37m‑win_amd64.whl
c) C:\Users...\Python37\Scripts>pip3.7 install C:...\pyproj‑2.6.0‑cp37‑cp37m‑win_amd64.whl
d) C:\Users...\Python37\Scripts>pip3.7 install C:...\Rtree‑0.9.4‑cp37‑cp37m‑win_amd64.whl
Given no errros, now it's good to go:
C:\Users...\Python37\Scripts>pip3.7.exe install geopandas
Test it using IDEL 3.7.4
import geopandas as pdg
(It works!)
This works for me and I hope this is also helpful for you.

I had trouble installing geopandas on (win-64, Spyder3.8, Python3.8.3)
Use this expression to install geopandas in anaconda prompt:
conda install -c conda-forge/label/cf202003 geos
(do not use this website: https://geopandas.org/install.html)
(do not use this expression: conda install --channel conda-forge geopandas)

The simplest method to install geopandas is:
conda install geopandas
In order to update geopandas to latest version use the following command after installation by conda:
pip install geopandas --upgrade
There are other installation methods also explained in Geopandas official website.
Conda is really powerful when it comes to installation as it will install the dependencies needed by the package. However, if you would like to install dependencies earlier than use the following command:
conda install pandas fiona shapely pyproj rtree descartes
Note that if you have installed the dependencies using above command then you can also use pip to install geopandas but before installing via pip dependencies are required to be installed. In order to read more about dependencies, please follow the official guide. To install using pip use the following command:
pip install geopandas

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?

Pandas not properly installed in venv

On ubuntu 16.4.4 with Python 2.7.12, I was trying to install pandas and some other packages with pip in virtualenv. The installation proceeded without any errors. However, when I try to import pandas, I get the following error:
RuntimeError: module compiled against API version 0xc but this version of numpy is 0xa
Traceback (most recent call last):
...
import pandas as pd
File "/usr/local/lib/python2.7/dist-packages/pandas/__init__.py", line 31, in <module>
"extensions first.".format(module))
ImportError: C extension: umpy.core.multiarray failed to import not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.
My system has pandas of the same version(0.18.0) and runs without any problem.
What I tried and did not work:
create a new virtualenv with the --system-site-packages option.
reinstall pandas (in venv)
upgrade pandas (in venv)
upgrade numpy (from 1.11.0 to 1.14.3) (in venv)
uninstall numpy and pandas and install pandas again (in venv)
This looks like a similar problem to this one https://github.com/pandas-dev/pandas/issues/18530 i.e. mismatch between some specific versions of numpy and pandas. The pip install numpy --upgrade didn't work for me but
python -m pip install pandas==0.18.0 --force-reinstall --upgrade --no-deps --no-cache
did the trick in my case (I encountered this problem on fresh Ubuntu 17.10, python2).
Update numpy version:
pip install numpy --upgrade
Should fix the error.

ImportError: cannot import name 'unique_everseen'

I'm trying to import quandl in to spyder (python 3.6) and I get the issues as seen in the title above. Could it be a fault with the more-itertools package, as I have not seen a file within the more_itertools folder which matches unique_everseen
File "C:\Program Files\Anaconda3\lib\site-
packages\quandl\model\merged_dataset.py", line 1, in <module>
from more_itertools import unique_everseen
I would recommend using pip to install the package since more_itertools is not yet an official package on conda. Activate the desired conda environment and install:
> activate <environment name>
> pip install more_itertools
See installation instructions here

Geopandas Installation

I am trying to install geopandas on my Mac OS X right now.
What I have done:
• Downloaded and installed Anaconda for Python 2.7 here. Graphical installer.
• python --version returns the following result: Python 2.7.13 :: Anaconda 4.3.0 (x86_64)
• Installed geopandas using this line : conda install -c conda-forge geopandas. This command also, as I understand, installed all other required packages. Here's the list of all that command installed:
click-plugins: 1.0.3-py27_0 conda-forge
cligj: 0.4.0-py27_0 conda-forge
descartes: 1.1.0-py27_0 conda-forge
expat: 2.1.0-2 conda-forge
fiona: 1.7.3-np111py27_0 conda-forge
freexl: 1.0.2-1 conda-forge
gdal: 2.1.3-np111py27_0 conda-forge
geopandas: 0.2.1-py27_3 conda-forge
geos: 3.5.1-1 conda-forge
giflib: 5.1.4-0 conda-forge
hdf4: 4.2.12-0 conda-forge
json-c: 0.12-0 conda-forge
kealib: 1.4.6-3 conda-forge
libdap4: 3.18.3-2 conda-forge
libnetcdf: 4.4.1.1-2 conda-forge
libpq: 9.5.4-3 conda-forge
libspatialindex: 1.8.5-1 conda-forge
libspatialite: 4.3.0a-14 conda-forge
munch: 2.1.0-py27_0 conda-forge
openjpeg: 2.1.2-2 conda-forge
pcre: 8.39-0 conda-forge
proj4: 4.9.3-2 conda-forge
psycopg2: 2.6.2-py27_1 conda-forge
pyproj: 1.9.5.1-py27_0 conda-forge
pysal: 1.13.0-py27_0 conda-forge
rtree: 0.8.3-py27_0 conda-forge
shapely: 1.5.17-np111py27_2 conda-forge
xerces-c: 3.1.4-0
• geopandas appears when I run conda list
• I wrote some code in test.py:
import geopandas as gpd
gpd.read_file("osm_mexico_city/mexico-city_mexico_roads.geojson")
The problem(s):
• When I run execute python test.py in the terminal I get the following error:
Traceback (most recent call last):
File "test.py", line 1, in <module>
import geopandas as gpd
File "//anaconda/lib/python2.7/site-packages/geopandas/__init__.py", line 4, in <module>
from geopandas.io.file import read_file
File "//anaconda/lib/python2.7/site-packages/geopandas/io/file.py", line 3, in <module>
import fiona
File "//anaconda/lib/python2.7/site-packages/fiona/__init__.py", line 69, in <module>
from fiona.collection import Collection, BytesCollection, vsi_path
File "//anaconda/lib/python2.7/site-packages/fiona/collection.py", line 9, in <module>
from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
ImportError: dlopen(//anaconda/lib/python2.7/site-packages/fiona/ogrext.so, 2): Library not loaded: #rpath/libpng16.16.dylib
Referenced from: //anaconda/lib/libgdal.20.dylib
Reason: Incompatible library version: libgdal.20.dylib requires version 45.0.0 or later, but libpng16.16.dylib provides version 44.0.0
• Second way I tried is through PyCharm. I have set the project interpreter to python 2.7. There geopandas does not appear in the package list, therefore PyCharm blocks even before that:
import geopandas as gpd
ImportError: No module named geopandas
Hope anyone has an idea of how to fix both.
UPDATE 1
After installing Anaconda brew doctor returns this now:
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: Anaconda is known to frequently break Homebrew builds, including Vim and
MacVim, due to bundling many duplicates of system and Homebrew-available
tools.
If you encounter a build failure please temporarily remove Anaconda
from your $PATH and attempt the build again prior to reporting the
failure to us. Thanks!
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
//anaconda/bin/curl-config
//anaconda/bin/dap-config
//anaconda/bin/freetype-config
//anaconda/bin/gdal-config
//anaconda/bin/geos-config
//anaconda/bin/icu-config
//anaconda/bin/kea-config
//anaconda/bin/libpng-config
//anaconda/bin/libpng16-config
//anaconda/bin/nc-config
//anaconda/bin/pcre-config
//anaconda/bin/python-config
//anaconda/bin/python2-config
//anaconda/bin/python2.7-config
//anaconda/bin/xml2-config
//anaconda/bin/xslt-config
Seems related to this issue. How do I fix these to make my stuff work?
UPDATE 2
We can forget about the PyCharm problem, it turns out somehow I had another python 2.7 and this is the one he was suggesting. I've changed it to the Anaconda python 2.7 and now it gives the same error as the terminal output.
Faced the same problem, and finally solved this through this method:
First install geopandas using conda (This will install all dependencies)
conda install -c conda-forge geopandas
Uninstall Fiona
conda uninstall fiona
Download fiona wheel and install
(I downloaded from here https://pypi.python.org/packages/71/ea/908bf078499b30d1ec374eb5baba016a568fc8142ee6ccf72e356d20871c/Fiona-1.7.4-cp27-cp27m-macosx_10_6_intel.whl#md5=971393c23ffc552664b7c694b992fb3e)
pip install Fiona-1.7.4-cp27-cp27m-macosx_10_6_intel.whl
Reinstall geopandas
pip install git+git://github.com/geopandas/geopandas.git
Not sure what happened with Anaconda, but it turns out the dependencies were not compatible.
conda install fiona=1.6
Downgrading Fiona to 1.6 solved everything for me.

Why is Python package Fiona is searching for Microsoft.VC90.DebugCRT?

I installed Python package Fiona. When I try to import it in my application, I get the following error:
File "C:\Anaconda3\lib\site-packages\fiona\collection.py", line 7, in
from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
ImportError: DLL load failed: The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.
I used Windows's "Event Viewer" and checked the problem:
Activation context generation failed for
"C:\Anaconda3\Library\bin\netcdf.dll". Dependent Assembly
Microsoft.VC90.DebugCRT,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"
could not be found. Please use sxstrace.exe for detailed diagnosis.
From this question I gather that some module is using a debug library, which it shouldn't. I thought that maybe it's GDAL? How can I detect whether Fiona itself or some dependency of Fiona is doing it?
I tried to uninstall Fiona (and GDAL) and reinstall them.
I can successfully uninstall and install them using:
conda uninstall fiona
conda uninstall gdal
conda install fiona
conda install gdal
But the error remains.
I got my code working by using the Windows binaries from the following page:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
and installing them with the command:
pip install C:\<path>\some_wheel.whl

Categories