Python Basemap Import error: "requirement already satisfied" [duplicate]
Asked Answered
E

4

13

What works is

import mpl_toolkits

What not works is (Import Error basemap not found)

from mpl_toolkits.basemap import Basemap

I followed the instructions here :

http://matplotlib.org/basemap/users/installing.html

Downloaded the lastest basemap*.tar.gz

I run the following commands:

Inside the geos folder

export GEOS_DIR=~/
./configure --prefix=$GEOS_DIR
make
make install

Inside the basemap folder

python setup.py install

Everything runs in sudo mode and no errors. Goes outputs no python binding but not as an error so i am not sure.

It seems not to be properly installed.

Mac Os X 10.10 Yosemite Python 2.7.6

if i type

pip install basemap --allow-external basemap --allow-unverified basemap

Requirement already satisfied (use --upgrade to upgrade): basemap in /Library/Python/2.7/site-packages

so it is there but not importable?

Eyas answered 26/1, 2015 at 19:21 Comment(8)
did you try re-installing with the --upgrade flag? your previous installation might incompletePostscript
and are you sure that GEO_DIR should be your home directory? is that where you want it? (note, with conda this whole process is conda install basemap and you're done)Postscript
no i have the python shipped with mac os x and want to keep it. the problem is that mpl_toolkits path is ['/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/mpl_toolkits'] but the default installation is /Library/Python/2.7/site-packages how can change this. i don't care where it is as long as it works.Eyas
Using conda doesn't touch Apple's PythonPostscript
yes but i got a lot of other packages that only work with the default python so i want to keep that.Eyas
That definitely doesn't preclude you from installing the conda package manager into your existing environment. Good luck.Postscript
Unfortunately it didn't work for me (10.10.5). This is the error message from port (executed as root): "Error: Port py-matplotlib-basemap not found". It looks like Port can't found the package. Maybe port needs to be configured in some ways?Goddaughter
This question has already been answered here, #40374941 For Windows specific problem, I believe the only difference is the environmental variables. I would highly suggest using Conda if you can. If you're using Mac, the easiest way to address the problem is by brew install geos pip install https://github.com/matplotlib/basemap/archive/master.zipMccool
R
8

What worked for me was this:

brew install gdal

For completeness, I did these things too:

conda install basemap

But this should be similar to your pip install method above.

Also, for completeness, I added this line to my .bash_profile:

export GEOS_DIR=/usr/local/Cellar/geos/3.4.2/

You may need to edit the version number.

Then, you can run:

from mpl_toolkits.basemap import Basemap
Remotion answered 4/8, 2015 at 21:15 Comment(4)
you can use brew instead: brew install matplotlib-basemap --with-python3Histoplasmosis
@Histoplasmosis your comment is no longer validWaterborne
@Waterborne looks like they removed it :( Seems like installing it is more involved now: #42299852Histoplasmosis
I had to compile it from sourceWaterborne
Y
2

The easiest way to install basemap on OS X is to use Ports.

Just type in the below command and the see the magic unfold:

port install  py-matplotlib-basemap
Yolande answered 27/11, 2015 at 7:33 Comment(0)
A
0

Correct me if I am wrong. Using MacPorts will install a "port" version of python.

If you started off with Anaconda python distribution, the easiest way is:

conda install -c anaconda basemap=1.0.7

Please see the page from Anaconda here

Arlberg answered 27/5, 2016 at 14:15 Comment(0)
P
0

The better way is upgrade matplotlib module as follows:

pip3 install matplotlib --upgrade
Palpate answered 28/11, 2019 at 17:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.