cartopy: ModuleNotFoundError: No module named 'cartopy'
Description
I have tried several ways to install the package cartopy on my Mac OS X with pip install cartopy and conda install -c conda-forge cartopy. As well as installing all the required dependencies as described in here: https://github.com/SciTools/cartopy/blob/master/INSTALL. Installation goes through, but when I try to import the module with:
import cartopy.crs as ccrs.
I get the error message:
Traceback (most recent call last): File “<stdin>”, line 1, in <module> ModuleNotFoundError: No module named ‘cartopy’
So then I have tried to follow the guidelines described in this post: http://louistiao.me/posts/installing-cartopy-on-mac-osx-1011/ . Which also have not solved the problem. It looks like the installation goes through without any problems, but when I want to import the module it does not regonize it. I can read that other Mac Users are also struggling with this, but I have not been able to find out if there is solution to the problem?
Code to reproduce
conda install cartopy
Traceback
Here is the traceback from one attempt:
(thesis_env) (venv) Idas-MacBook-Pro-4:scripts ida$ conda install cartopy
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /Users/ida/opt/anaconda3/envs/thesis_env
added / updated specs:
- cartopy
The following packages will be downloaded:
package | build
---------------------------|-----------------
ca-certificates-2020.4.5.1 | hecc5488_0 146 KB conda-forge
cartopy-0.17.0 |py37h8ad5b2f_1015 1.7 MB conda-forge
certifi-2020.4.5.1 | py37hc8dfbb8_0 151 KB conda-forge
geos-3.8.1 | h4a8c4bd_0 901 KB conda-forge
openssl-1.1.1f | h0b31af3_0 1.9 MB conda-forge
owslib-0.19.2 | py_1 126 KB conda-forge
proj-7.0.0 | h22d00a4_2 3.6 MB conda-forge
pyproj-2.6.0 | py37hbd4ead9_1 374 KB conda-forge
shapely-1.7.0 | py37hfcf0db4_3 409 KB conda-forge
------------------------------------------------------------
Total: 9.2 MB
The following NEW packages will be INSTALLED:
cartopy conda-forge/osx-64::cartopy-0.17.0-py37h8ad5b2f_1015
geos conda-forge/osx-64::geos-3.8.1-h4a8c4bd_0
owslib conda-forge/noarch::owslib-0.19.2-py_1
proj conda-forge/osx-64::proj-7.0.0-h22d00a4_2
pyepsg conda-forge/noarch::pyepsg-0.4.0-py_0
pykdtree conda-forge/osx-64::pykdtree-1.3.1-py37h10e2902_1003
pyproj conda-forge/osx-64::pyproj-2.6.0-py37hbd4ead9_1
pyshp conda-forge/noarch::pyshp-2.1.0-py_0
shapely conda-forge/osx-64::shapely-1.7.0-py37hfcf0db4_3
The following packages will be UPDATED:
ca-certificates 2019.11.28-hecc5488_0 --> 2020.4.5.1-hecc5488_0
certifi 2019.11.28-py37hc8dfbb8_1 --> 2020.4.5.1-py37hc8dfbb8_0
openssl 1.1.1d-h0b31af3_0 --> 1.1.1f-h0b31af3_0
Proceed ([y]/n)? y
Downloading and Extracting Packages
geos-3.8.1 | 901 KB | ###################################################################################################################################### | 100%
pyproj-2.6.0 | 374 KB | ###################################################################################################################################### | 100%
proj-7.0.0 | 3.6 MB | ###################################################################################################################################### | 100%
owslib-0.19.2 | 126 KB | ###################################################################################################################################### | 100%
shapely-1.7.0 | 409 KB | ###################################################################################################################################### | 100%
openssl-1.1.1f | 1.9 MB | ###################################################################################################################################### | 100%
certifi-2020.4.5.1 | 151 KB | ###################################################################################################################################### | 100%
cartopy-0.17.0 | 1.7 MB | ###################################################################################################################################### | 100%
ca-certificates-2020 | 146 KB | ###################################################################################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
Full environment definition
Operating system
Mac OS X
Cartopy version
conda list
# packages in environment at /Users/ida/opt/anaconda3/envs/thesis_env:
#
# Name Version Build Channel
alabaster 0.7.12 py_0 conda-forge
appnope 0.1.0 py37_1000 conda-forge
astroid 2.3.3 py37_1 conda-forge
attrs 19.3.0 py_0 conda-forge
babel 2.8.0 py_0 conda-forge
backcall 0.1.0 py_0 conda-forge
bleach 3.1.1 py_0 conda-forge
bokeh 2.0.0 py37hc8dfbb8_0 conda-forge
bottleneck 1.3.2 py37h3b54f70_0 conda-forge
bzip2 1.0.8 h0b31af3_2 conda-forge
ca-certificates 2020.4.5.1 hecc5488_0 conda-forge
cartopy 0.17.0 py37h8ad5b2f_1015 conda-forge
certifi 2020.4.5.1 py37hc8dfbb8_0 conda-forge
cffi 1.13.2 py37h33e799b_0 conda-forge
cftime 1.0.4.2 py37h3b54f70_0 conda-forge
chardet 3.0.4 py37_1003 conda-forge
click 7.1.1 pyh8c360ce_0 conda-forge
cloudpickle 1.3.0 py_0 conda-forge
cryptography 2.8 py37hafa8578_1 conda-forge
curl 7.68.0 h8754def_0 conda-forge
cycler 0.10.0 py_2 conda-forge
cytoolz 0.10.1 py37h0b31af3_0 conda-forge
dask 2.12.0 py_0 conda-forge
dask-core 2.12.0 py_0 conda-forge
dbus 1.13.6 h2f22bb5_0 conda-forge
decorator 4.4.1 py_0 conda-forge
defusedxml 0.6.0 py_0 conda-forge
distributed 2.12.0 py37_0 conda-forge
docutils 0.16 py37_0 conda-forge
entrypoints 0.3 py37_1000 conda-forge
expat 2.2.9 h4a8c4bd_2 conda-forge
freetype 2.10.0 h24853df_1 conda-forge
fsspec 0.6.2 py_0 conda-forge
geos 3.8.1 h4a8c4bd_0 conda-forge
gettext 0.19.8.1 h46ab8bc_1002 conda-forge
glib 2.58.3 py37h577aef8_1002 conda-forge
hdf4 4.2.13 h84186c3_1003 conda-forge
hdf5 1.10.5 nompi_h3e39495_1104 conda-forge
heapdict 1.0.1 py_0 conda-forge
icu 64.2 h6de7cb9_1 conda-forge
idna 2.9 py_1 conda-forge
imagesize 1.2.0 py_0 conda-forge
importlib_metadata 1.5.0 py37_0 conda-forge
ipykernel 5.1.4 py37h5ca1d4c_0 conda-forge
ipython 7.12.0 py37h5ca1d4c_0 conda-forge
ipython_genutils 0.2.0 py_1 conda-forge
isort 4.3.21 py37_0 conda-forge
jedi 0.16.0 py37_0 conda-forge
jinja2 2.11.1 py_0 conda-forge
jpeg 9c h1de35cc_1001 conda-forge
jsonschema 3.2.0 py37_0 conda-forge
jupyter_client 5.3.4 py37_1 conda-forge
jupyter_core 4.6.3 py37_0 conda-forge
keyring 21.1.0 py37_0 conda-forge
kiwisolver 1.1.0 py37ha1b3eb9_0 conda-forge
krb5 1.16.4 h1752a42_0 conda-forge
lazy-object-proxy 1.4.3 py37h0b31af3_1 conda-forge
libblas 3.8.0 15_openblas conda-forge
libcblas 3.8.0 15_openblas conda-forge
libclang 8.0.1 h770b8ee_1 conda-forge
libcurl 7.68.0 h709d2b2_0 conda-forge
libcxx 9.0.1 1 conda-forge
libedit 3.1.20170329 hcfe32e1_1001 conda-forge
libffi 3.2.1 h6de7cb9_1006 conda-forge
libgfortran 4.0.0 2 conda-forge
libiconv 1.15 h01d97ff_1005 conda-forge
liblapack 3.8.0 15_openblas conda-forge
libllvm8 8.0.1 h770b8ee_0 conda-forge
libnetcdf 4.7.3 nompi_hda4e5f1_101 conda-forge
libopenblas 0.3.8 h3d69b6c_0 conda-forge
libpng 1.6.37 h2573ce8_0 conda-forge
libsodium 1.0.17 h01d97ff_0 conda-forge
libssh2 1.8.2 hcdc9a53_2 conda-forge
libtiff 4.1.0 ha78913b_3 conda-forge
llvm-openmp 9.0.1 h28b9765_2 conda-forge
locket 0.2.0 py_2 conda-forge
lz4-c 1.8.3 h6de7cb9_1001 conda-forge
markupsafe 1.1.1 py37h0b31af3_0 conda-forge
matplotlib 3.1.3 py37_0 conda-forge
matplotlib-base 3.1.3 py37h11da6c2_0 conda-forge
mccabe 0.6.1 py_1 conda-forge
mistune 0.8.4 py37h0b31af3_1000 conda-forge
msgpack-python 1.0.0 py37ha1b3eb9_0 conda-forge
nbconvert 5.6.1 py37_0 conda-forge
nbformat 5.0.4 py_0 conda-forge
ncurses 6.1 h0a44026_1002 conda-forge
netcdf4 1.5.3 nompi_py37hcf2264a_102 conda-forge
nspr 4.20 h0a44026_1000 conda-forge
nss 3.47 hc0980d9_0 conda-forge
numpy 1.18.1 py37hde6bac1_0 conda-forge
numpydoc 0.9.2 py_0 conda-forge
olefile 0.46 py_0 conda-forge
openssl 1.1.1f h0b31af3_0 conda-forge
owslib 0.19.2 py_1 conda-forge
packaging 20.1 py_0 conda-forge
pandas 1.0.1 py37h4f17bb1_0 conda-forge
pandoc 2.9.2 0 conda-forge
pandocfilters 1.4.2 py_1 conda-forge
parso 0.6.1 py_0 conda-forge
partd 1.1.0 py_0 conda-forge
pcre 8.44 h4a8c4bd_0 conda-forge
pexpect 4.8.0 py37_0 conda-forge
pickleshare 0.7.5 py37_1000 conda-forge
pillow 7.0.0 py37hfd78ece_1 conda-forge
pip 20.0.2 py_2 conda-forge
proj 7.0.0 h22d00a4_2 conda-forge
prompt_toolkit 3.0.3 py_0 conda-forge
psutil 5.7.0 py37h0b31af3_0 conda-forge
ptyprocess 0.6.0 py_1001 conda-forge
pycodestyle 2.5.0 py_0 conda-forge
pycparser 2.19 py_2 conda-forge
pyepsg 0.4.0 py_0 conda-forge
pyflakes 2.1.1 py_0 conda-forge
pygments 2.5.2 py_0 conda-forge
pykdtree 1.3.1 py37h10e2902_1003 conda-forge
pylint 2.4.4 py37_0 conda-forge
pyopenssl 19.1.0 py_1 conda-forge
pyparsing 2.4.6 py_0 conda-forge
pyproj 2.6.0 py37hbd4ead9_1 conda-forge
pyqt 5.12.3 py37he22c54c_1 conda-forge
pyqt5-sip 4.19.18 pypi_0 pypi
pyqtwebengine 5.12.1 pypi_0 pypi
pyrsistent 0.15.7 py37h0b31af3_0 conda-forge
pyshp 2.1.0 py_0 conda-forge
pysocks 1.7.1 py37_0 conda-forge
python 3.7.6 h5c2c468_2 conda-forge
python-dateutil 2.8.1 py_0 conda-forge
python.app 1.2 py37h0b31af3_1201 conda-forge
python_abi 3.7 1_cp37m conda-forge
pytz 2019.3 py_0 conda-forge
pyyaml 5.3 py37h0b31af3_0 conda-forge
pyzmq 18.1.1 py37h4bf09a9_0 conda-forge
qt 5.12.5 h1b46049_0 conda-forge
qtawesome 0.7.0 py_0 conda-forge
qtconsole 4.6.0 py_0 conda-forge
qtpy 1.9.0 py_0 conda-forge
readline 8.0 hcfe32e1_0 conda-forge
requests 2.23.0 py37_0 conda-forge
rope 0.16.0 py_0 conda-forge
scipy 1.4.1 py37h82752d6_0 conda-forge
setuptools 45.2.0 py37_0 conda-forge
shapely 1.7.0 py37hfcf0db4_3 conda-forge
six 1.14.0 py37_0 conda-forge
snowballstemmer 2.0.0 py_0 conda-forge
sortedcontainers 2.1.0 py_0 conda-forge
sphinx 2.4.3 py_0 conda-forge
sphinxcontrib-applehelp 1.0.1 py_0 conda-forge
sphinxcontrib-devhelp 1.0.1 py_0 conda-forge
sphinxcontrib-htmlhelp 1.0.3 py_0 conda-forge
sphinxcontrib-jsmath 1.0.1 py_0 conda-forge
sphinxcontrib-qthelp 1.0.2 py_0 conda-forge
sphinxcontrib-serializinghtml 1.1.3 py_0 conda-forge
spyder 3.3.6 py37_0
spyder-kernels 0.5.2 py37_0
sqlite 3.30.1 h93121df_0 conda-forge
tblib 1.6.0 py_0 conda-forge
testpath 0.4.4 py_0 conda-forge
tk 8.6.10 hbbe82c9_0 conda-forge
toolz 0.10.0 py_0 conda-forge
tornado 6.0.3 py37h0b31af3_4 conda-forge
traitlets 4.3.3 py37_0 conda-forge
typed-ast 1.4.1 py37h0b31af3_0 conda-forge
typing_extensions 3.7.4.1 py37_0 conda-forge
urllib3 1.25.7 py37_0 conda-forge
wcwidth 0.1.8 py_0 conda-forge
webencodings 0.5.1 py_1 conda-forge
wheel 0.34.2 py_1 conda-forge
wrapt 1.12.0 py37h0b31af3_0 conda-forge
wurlitzer 2.0.0 py37_0 conda-forge
xarray 0.15.0 py_0 conda-forge
xz 5.2.4 h1de35cc_1001 conda-forge
yaml 0.2.2 h0b31af3_1 conda-forge
zeromq 4.3.2 h6de7cb9_2 conda-forge
zict 2.0.0 py_0 conda-forge
zipp 3.0.0 py_0 conda-forge
zlib 1.2.11 h0b31af3_1006 conda-forge
zstd 1.4.4 he7fca8b_1 conda-forge
pip list
Package Version
----------------- ------------
attrs 19.3.0
bokeh 2.0.1
branca 0.4.0
certifi 2019.11.28
cftime 1.1.0
chardet 3.0.4
click 7.1.1
click-plugins 1.1.1
cligj 0.5.0
cloudpickle 1.3.0
cycler 0.10.0
Cython 0.29.16
dask 2.14.0
descartes 1.1.0
distributed 2.14.0
et-xmlfile 1.0.1
Fiona 1.8.13.post1
folium 0.10.1
fsspec 0.7.2
geopandas 0.3.0
HeapDict 1.0.1
idna 2.9
jdcal 1.4.1
Jinja2 2.11.1
joblib 0.14.1
kiwisolver 1.1.0
locket 0.2.0
MarkupSafe 1.1.1
matplotlib 3.1.3
MetPy 0.9.0
msgpack 1.0.0
munch 2.5.0
netCDF4 1.5.3
numpy 1.18.2
openpyxl 3.0.3
packaging 20.3
pandas 1.0.1
partd 1.1.0
Pillow 7.1.1
Pint 0.11
pip 19.0.3
plotly 4.5.4
pooch 0.1
psutil 5.7.0
pyparsing 2.4.6
pyproj 2.6.0
pyshp 2.1.0
python-dateutil 2.8.1
pytz 2019.3
PyYAML 5.3.1
requests 2.23.0
retrying 1.3.3
scipy 1.4.1
seaborn 0.10.0
setuptools 40.8.0
Shapely 1.7.0
six 1.14.0
sortedcontainers 2.1.0
tblib 1.6.0
toolz 0.10.0
tornado 6.0.4
typing-extensions 3.7.4.2
urllib3 1.25.8
xarray 0.15.0
zict 2.0.0
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (7 by maintainers)
Thank You so much, you were right. It’s working now.
Hi @VikasAmaraneni, it looks like you have named one of your own files
cartopy.pyin your top level home directory. Try renaming that file to something else, as python is importing that rather than the package.Hii, I’m facing the same issue:

Can anyone help me with this. I’ve tried uninstalling the cartopy and installing it again. I’ve created a new venv for this. But still facing the issue.
Nothing strikes me as immediately wrong there. Are you importing Cartopy from the right environment? It looks like you may have both venvs and conda envs both at work here, which may confuse things.
This works for me on a mac: