Basemap install on mac without fink (I tried everything I can google) - macos

I am a Python Noob. (Using Mac OS 10.12 & Python 3.7)
I'm trying to use mpl_toolkits.basemap
to execute the code
from mpl_toolkits.basemap import Basemap
I googled the way to get matplotlib and successfully installed it.
However, while it's possible to run "from mpl_toolkits.basemap import Basemap" in terminal on mac,
it fails to be loaded if I run the command within IDLE.
Then, I googled to figure out the issue and got the hint that
it could be resolved if I install Basemap properly.
To install Basemap, I think I need to go with "FINK".
However, Fink is only available up to 10.5 OS while mine is 10.12.
And FINK website says do not update OS before upgrading FINK.
However, it's too late for me.
Cause I updated my OS longtime ago and recently I started to learn Python Using Mac.
So I guess, if there is a way to install Basemap not using apt-get,
(the codes below is from "Python basemap module impossible to import")
sudo apt-get install libgeos-3.5.0
sudo apt-get install libgeos-dev
sudo pip install https://github.com/matplotlib/basemap/archive/master.zip
I think my issue could be cleared.
Since I'm really really noob, I'm not sure this is the reason for my failing in "from mpl_toolkits.basemap import Basemap".
What I tried so far is
1) brew install basemap
with the error of
Error: No available formula with the name "basemap"
==> Searching for a previously deleted formula (in the last month)... Warning: homebrew/core is shallow clone. To get complete history run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow
2) pip install basemap
with the error of
Requirement already satisfied
3) sudo pip install https://github.com/matplotlib/basemap/archive/master.zip
with the error of
Command "python setup.py egg_info" failed with error code 1 in
/private/tmp/pip-install-lux494o4/pyproj/
4) conda install basemap
with the following message of
All requested packages already installed.
5) conda install -c conda-forge basemap
with the following message
Preparing transaction: done Verifying transaction: done Executing
transaction: done
Can anyone help to install basemap properly so that I could run
"from mpl_toolkits.basemap import Basemap"
in my IDLe?
My IDLE Sheel keeps saying
Traceback (most recent call last): File "", line 1, in
from mpl_toolkits.basemap import Basemap ModuleNotFoundError: No module named 'mpl_toolkits.basemap'
while my terminal doesn't have problem with running the code.
Appreciate it in advance.

any luck? I spent the day battling this as well. I had the most success when I tried downloading an older version of basemap.
I was using python 2.7 and this worked okay sudo -H pip2 install https://github.com/matplotlib/basemap/archive/v1.1.0.tar.gz
For python 3 try replacing pip2 with pip3 or pip.

Ran into this myself today my solution:
install libgeos on mac
brew install geos
then as you suggested use pip to install mpl_tools:
pip3 install -q https://github.com/matplotlib/basemap/archive/master.zip
This also may help:
missing libgeos_c.so on OSX

Firstly, I suggest you to set Anaconda up. Then follow below steps;
Create a new environment in anaconda.
Install Jupyter Notebook and launch it. If it works, turn it off.
Change your anaconda environment in your terminal.
Try installation commands below;
conda install ...
conda install forge ...
pip install ...

Related

pip trying to install using old version of python

so I just uninstalled a wrong version of python 3.8 and downloaded python 3.7.4
Now I'm trying to install packages using the command pip install X and get the following error.
C:\Users\User>pip install cv2
Fatal error in launcher: Unable to create process using '"c:\users\user\appdata\local\programs\python\python38-32\python.exe" "C:\Users\User\AppData\Local\Programs\Python\Python38-32\Scripts\pip.exe" install cv2': The system cannot find the file specified.
clearly it is still trying to use the old version of python 3.8 even though I have uninstalled it and reinstalled pip several times.
Any idea on why its trying to look for this old path? and how can I change the default path it is using?
(btw this is just a matter of convenience because as of the moment if I use the command python -m pip install X it does seem to work)
try command python -m pip install --upgrade pip
Delete and clear environment config and install again...

Trying to install pygame on OSX 10.11 for python2

I'm running OSX 10.11 and have python 2.7.10 installed on my computer. I want to install pygame1.9.2 for the said environment (don't want to install it for python3 which is installed on my computer as well).
When I try to install this one - http://www.pygame.org/ftp/pygame-1.9.2pre-py2.7-macosx10.7.mpkg.zip - it says, "This package is incompatible with this version of OS X and may fail to install." Even if I continue, installation fails somehow.
I tried "pip install pygame" then it says
"Collecting pygame Could not find a version that satisfies the
requirement pygame (from versions: ) No matching distribution found
for pygame. "
How do I install it?
(for future reference) After spending many hours I found the following command to be working!
sudo pip install --user git+https://github.com/pygame/pygame/
It's not 1.9.2 but can run what I wanted with python 2.7.10
>>> pygame.__version__
'2.0.0.dev0'

installing cvxopt on windows 10 using anaconda python 3.*

I've been trying to install cvxopt on Anaconda Python 3.x for a while now, reading past posts and I can't seem to make it work. Here is what I have tried so far:
pip install cvxopt --user
which gave me the following error:
Failed building wheel for cvxopt
Then I tried this:
conda install -c omnia cvxopt
output:
UnsatisfiableError: The following specifications were found to be in conflict:
- cvxopt
- python 3.5*
I installed mkl using this:
conda install mkl
which worked but trying out the previous commands still don't work.
I have installed multiple things in the past using the command prompt but my experience has told me to make sure I know and understand what I am installing because I wrecked my computer one time. So instead of trying things blindly, I would like to know if someone had a tipp.
As you can see here cvxopt does not support python 3.5+ due to compiler incompatibility.
Nevertheless, as stated in the comments, you can use anacodna to create a virtual environment and install it.
conda create --name py34 python=3.4 numpy
activate py34
conda install -c omnia cvxopt

Using pip to install iPython Notebook

Edit:
According to the pip website (https://pip.pypa.io/en/stable/installing), I should already have pip installed with my Python version 2.9.7, but I assumed that I don't because of the error message.
I then attempted to install pip by downloading get-pip.py. It was successful but I got the messages:
Found existing installation: pip 1.3.1
Uninstalling pip-1.3.1:
Successfully uninstalled pip-1.3.1
Successfully installed pip-8.1.1 wheel-0.29.0
So it seems I did have a version of pip, so I'm not sure why I was getting the error message described in my original post.
But when I tried to then pip install jupyter, I just get:
-bash: pip: command not found
again. Can someone tell me what I'm doing wrong please?
I need to install iPython Notebook. I already have Python (version 2.7.9) installed on my Macbook, running OS X (version 10.7.5).
After some initial investigation, I saw somebody say that I could just run:
pip install "ipython[notebook]"
When I did this however, I got:
-bash: pip: command not found
So do I have to install pip first? And then use pip to install the Notebook? I'm out of my depth and a little confused!
Okay so my problem was that pip was installed, but in a location that was not included in my $PATH variable.
One of the answers here is relevant.

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

This question already has answers here:
Python basemap module impossible to import
(18 answers)
Closed 2 years ago.
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?
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
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
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
The better way is upgrade matplotlib module as follows:
pip3 install matplotlib --upgrade

Resources