Geopandas Installation - python

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.

Related

Error when upgrading Spyder to 4.0.1: ModuleNotFoundError: No module named 'IPython.core.inputtransformer2'

I recently upgraded to Spyder 4.0.1 through Anaconda via conda update spyder. Now, when I try to boot up Spyder via Anaconda Navigator, the program automatically crashes with the following dump:
Traceback (most recent call last):
File "/Users/ed/anaconda/lib/python3.6/site-packages/spyder/app/mainwindow.py", line 3718, in main
mainwindow = run_spyder(app, options, args)
File "/Users/ed/anaconda/lib/python3.6/site-packages/spyder/app/mainwindow.py", line 3559, in run_spyder
main.setup()
File "/Users/ed/anaconda/lib/python3.6/site-packages/spyder/app/mainwindow.py", line 1010, in setup
from spyder.plugins.ipythonconsole.plugin import IPythonConsole
File "/Users/ed/anaconda/lib/python3.6/site-packages/spyder/plugins/ipythonconsole/plugin.py", line 52, in
from spyder.plugins.ipythonconsole.widgets import ClientWidget
File "/Users/ed/anaconda/lib/python3.6/site-packages/spyder/plugins/ipythonconsole/widgets/__init__.py", line 16, in
from .debugging import DebuggingWidget
File "/Users/ed/anaconda/lib/python3.6/site-packages/spyder/plugins/ipythonconsole/widgets/debugging.py", line 22, in
from IPython.core.inputtransformer2 import TransformerManager
ModuleNotFoundError: No module named 'IPython.core.inputtransformer2'
I couldn't find anybody with a similar error. I updated IPython, as someone suggested, but it did not resolve the problem. Any ideas?
... since none of this worked for me, here how I solved it:
check what IPython version you have via conda list
in my case i got a rather old version 5.8.0 instead of the most recent one
(at the time of writing 7.19.0... check available versions via conda search ipython)
since conda update ipython did not provide the most recent version, i decided
to manually run the command that installs the most recent version
(for me this was conda install -c conda-forge ipython=7.19.0)
that's it...
I had the same problem. Upgrading IPython via the following command line helped resolve the situation.
sudo conda update IPython -n xxx
where xxx is the name of the environment I was trying to run Spyder in.
I had this very same issue on Spyder 4.1.4. Turns out that not all the required packages were installed correctly when I installed Spyder.
I used the following in python to test IPython:
import IPython
print(IPython.__version__)
Turned out that I had 6.4.0 so I ran the following from the terminal:
!pip install --upgrade IPython
IPython 7.16.1 was installed with prompt_toolkit-3.0.5. I also got the following errors:
ERROR: spyder 4.1.4 requires pyqt5<5.13; python_version >= "3", which is not installed.
ERROR: spyder 4.1.4 requires pyqtwebengine<5.13; python_version >= "3", which is not installed.
ERROR: jupyter-console 5.2.0 has requirement prompt-toolkit<2.0.0,>=1.0.0, but you'll have prompt-toolkit 3.0.5 which is incompatible.
ERROR: spyder 4.1.4 has requirement jedi==0.17.1, but you'll have jedi 0.12.1 which is incompatible.
ERROR: spyder 4.1.4 has requirement parso==0.7.0, but you'll have parso 0.3.0 which is incompatible.
ERROR: spyder 4.1.4 has requirement qtconsole>=4.6.0, but you'll have qtconsole 4.3.1 which is incompatible.
ERROR: spyder-kernels 1.9.2 has requirement ipykernel>=5.1.3; python_version > "2", but you'll have ipykernel 4.8.2 which is incompatible.
ERROR: spyder-kernels 1.9.2 has requirement jupyter-client>=5.3.4, but you'll have jupyter-client 5.2.3 which is incompatible.
Installing the correct versions of the above packages in pip resolved my problem.
Update to python 3.7. I had the same problem. That solved it.
conda install python=3.7 anaconda=custom
I experienced the same problem. Just do conda update IPython. All good then!

pip install geopandas on windows

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

Cannot import category_encoders module

I am not able to import category_encoders module in jupyter notebook in python 3 virtual environment.
Error
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-15-86725efc8d1e> in <module>()
9 from plotly import graph_objs
10 from datetime import datetime
---> 11 import category_encoders as ce
12
13 import sklearn
ModuleNotFoundError: No module named 'category_encoders'
Output of "which pip"
/opt/virtual_env/py3/bin/pip
Output of "pip show category_encoders" is
Name: category-encoders
Version: 1.3.0
Summary: A collection sklearn transformers to encode categorical variables as numeric
Home-page: https://github.com/wdm0006/categorical_encoding
Author: Will McGinnis
Author-email: will#pedalwrencher.com
License: BSD
Location: /opt/virtual_env/py3/lib/python3.6/site-packages
Requires: numpy, pandas, statsmodels, scikit-learn, patsy, scipy
Required-by:
Output of "pip list"
Package Version
------------------- -------
absl-py 0.7.0
astor 0.7.1
backcall 0.1.0
category-encoders 1.3.0
cycler 0.10.0
pip install --upgrade category_encoders
Now,
Restart your kernel
import category_encoders as... so on and so forth
Also,
you can checkout the sk-learn's preprocessing class CategoricalEncoder...
from sklearn.preprocessing import CategoricalEncoder
get sk-learn from here,
pip install git+git://github.com/scikit-learn/scikit-learn.git
or Simply
pip install sklearn
I was using anaconda environment.
Initially, I installed category_encoders using pip (within the conda enviornment) and it failed to resolve. Then I uninstalled ``category_encoders` from pip
pip uninstall category-encoders
and installed it using conda:
conda install -c conda-forge category_encoders
That solved the issue.
If you have given your virtual environment ('py3' for your case) the permission for accessing the system site-packages directory you can try installing the package to your base (root) environment.
Search 'pyvenv.cfg' file in your system and check if it includes:
include-system-site-packages = true
If yes, install the package to your root environment as stated here and try importing it again in your Jupyter Notebook.
You can add a cell above and type ! pip install --upgrade category_encoders
It will install the package without opening a terminal window.

Installing a package (conda) results in ImportError: Library not loaded

I installed seaborn package through conda:
~user: conda install seaborn
The following NEW packages will be INSTALLED:
seaborn: 0.8-py27_0
The following packages will be UPDATED:
conda: 4.3.8-py27_0 --> 4.3.30-py27h407ed3a_0
matplotlib: 1.4.3-np19py27_2 --> 1.5.3-np111py27_1
statsmodels: 0.6.1-np19py27_0 --> 0.8.0-np111py27_0
And it messed up my matplotlib installation, now when I run my python script, it raises an error when importing matplotlib:
ImportError: dlopen(/Users/.../anaconda/lib/python2.7/site-packages/matplotlib/_png.so, 2): Library not loaded: #rpath/libpng16.16.dylib
Referenced from: /Users/.../anaconda/lib/python2.7/site-packages/matplotlib/_png.so
Reason: Incompatible library version: _png.so requires version 39.0.0 or later, but libpng16.16.dylib provides version 34.0.0
This error can be caused by old version of conda. You need to first update conda and then try again.
conda update conda
Try this from your conda command prompt:
conda install -c anaconda seaborn

Can't use Jupyter Notebook: jsonschema apparently missing

When using an Anaconda environment, I can't start Jupyter to work in a notebook. I can do so without the environment, but I need to be able to use the environment. Here's what I do and the errors I get:
ben#ben-K60IJ:~/surveillance_sound_classifier/surveillance_sound_classifier$ source activate EECS352
discarding /home/ben/anaconda/bin from PATH
prepending /home/ben/anaconda/envs/EECS352/bin to PATH
(EECS352)ben#ben-K60IJ:~/surveillance_sound_classifier/surveillance_sound_classifier$ jupyter notebook
Traceback (most recent call last):
File "/home/ben/anaconda/envs/EECS352/bin/jupyter-notebook", line 4, in <module>
import notebook.notebookapp
File "/home/ben/anaconda/envs/EECS352/lib/python2.7/site-packages/notebook/notebookapp.py", line 61, in <module>
from .services.contents.manager import ContentsManager
File "/home/ben/anaconda/envs/EECS352/lib/python2.7/site-packages/notebook/services/contents/manager.py", line 16, in <module>
from nbformat import sign, validate, ValidationError
File "/home/ben/anaconda/envs/EECS352/lib/python2.7/site-packages/nbformat/__init__.py", line 33, in <module>
from .validator import validate, ValidationError
File "/home/ben/anaconda/envs/EECS352/lib/python2.7/site-packages/nbformat/validator.py", line 21, in <module>
raise ImportError(str(e) + verbose_msg)
ImportError: No module named functools32
Jupyter notebook format depends on the jsonschema package:
https://pypi.python.org/pypi/jsonschema
Please install it first.
Yes, I've done pip install jsonschema and conda install jsonschema AND pip install functools32 and conda install functools32 from within the EECS352 environment to no avail; I arrive at an almost identical error, except this time, functools32 is replaced with _version.
I've reinstalled Anaconda, updated all its packages, created a new environment in the same way I created this one, and still I get this error. I'm using Ubuntu 15.10 32-bit. I used to be able to use this environment with no problems until roughly a week ago.
If this is a duplicate, please point me to the original; however, I haven't yet found anything that seems really relevant. The only thing that might be relevant is that this error did pop up after I modified some .conf file because I was having issues updating my computer's software using sudo apt-get upgrade. I don't recall what I had done and to which file, but if it's likely the source of this issue, I can spend some time trying to track it down. Please let me know if I should spend my time to do this, and I will.
I think I have a solution.
I did may things, regenerated my env (anaconda env) from another computer where it worked, but no success.
What I think that nailed it is upgrading jsonschema to 2.5.1
Here are my steps from "bad" jupyter env to working jupyter env.
Good luck and come back if it doesn't work, I will post the notebook* relevant versions.
>conda upgrade pip
pip: 8.1.0-py27_0 --> 8.1.1-py27_0
setuptools: 20.2.2-py27_0 --> 20.3-py27_0
>pip install functools32
Downloading functools32-3.2.3-2.tar.gz
Successfully installed functools32-3.2.3.post2
>jupyter notebook
ImportError: No module named _version
Jupyter notebook format depends on the jsonschema package:
https://pypi.python.org/pypi/jsonschema
Please install it first.
>pip install jsonschema
Requirement already satisfied
>pip install --upgrade jsonschema
Collecting jsonschema
Downloading jsonschema-2.5.1-py2.py3-none-any.whl
Successfully uninstalled jsonschema-2.4.0
Successfully installed jsonschema-2.5.1
>jupyter notebook
[I 16:45:41.708 NotebookApp] Writing notebook server cookie secret to
[I 16:45:42.134 NotebookApp] Serving notebooks from local directory:
[I 16:45:42.134 NotebookApp] 0 active kernels
[I 16:45:42.134 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
i also got the same error and none of the above mentioned procedures worked for me so i've checked the documentation of anaconda and found something useful
conda install -c conda-forge/label/cf201901 jsonschema
conda install jupyter
jupyter notebook
this worked for me,thanks to anaconda documentation
Re-install jsonschema solve the problem in my case:
$ pip uninstall jsonschema
...
$ pip install jsonschema
...
If any of the above mentioned solution didn't work then try this in your anaconda prompt: First run conda update -n root conda so you have the latest conda version installed. Then run conda update --all This will update all packages in the current environment to the latest version.
Even after installing jsonschema, your Jupyter Notebook might not run and give you the error:
Jupyter notebook format depends on the jsonschema package:
https://pypi.python.org/pypi/jsonschema
Please install it first
Then I suggest you to run the given two commands. It will solve your issue as it solved mine.
Try this from the terminal:
pip install ipython[notebook]
It worked for me, let me know if the problem still exists.
I had the same problem.
I solved it by running this command
conda install -c anaconda jsonschema
https://anaconda.org/anaconda/jsonschema
I solved it by just uninstalling and reinstalling python 3.7
Try this from terminal, it worked to me:
pip install --upgrade pyrsistent

Categories