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

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

Related

How to avoid pip install package again while conda install was done before?

guys:
I use conda install tensorflow-gputo install tensorflow 2.0 , and
numpy=1.20.2 would be one of the package installed, and then I use python3 -m pip install SOMEPACKAGE ,this SOMEPACKAGE needs numpy to be installed as well , but pip seems does not check or realize the package numpy has already installed...
I would like to show everything I know so far :
1.I know the packages installed via conda install would go to anaconda3/envs/YOUR_ENV/lib/site-packages
2.I use python3 -m pip install -t anaconda3/envs/YOUR_ENV/lib/site-packages to force the package would be installed to the place where conda install would be.
However,pip still tries to dwonload *.whl file and install package again,I do not want this package installation process happen again ,while it did mention that I can use --upgrade to replace the existed package...
So I would like to know
How does pip and conda install check if the target package has already existed before they actually to through install process?
I think using python3 you are not using interpreter from your current conda environment so it gets installed elsewhere
python -m pip install (or simply pip install) from your activated environment should work and ignore dependencies installed by conda if they satisfy the requirements

No module named pymc3

HI i'm trying to import pymc3 after pip installing it from the command line within the library where Python.exe sits in. (i.e. >>python -m pip install pymc3). after checking the Lib/Site-Packages library, there's no pymc3, but there is a theanos package installed though. i've looked everywhere for the pymc3 package but can't find it. i've tried installing pymc4 and same thing happens. any idea why?
You should be able to run pip straight for command line.
IE: the command is "pip install pymc3"
Then you would need to import it.
Your issue might also be that you recently installed python and have pip3 installed and not pip. You can check if pip vs pip3 is installed with pip --version and pip3 --version.
Whichever one of those responds with some form of pip XX.X.X from /.... would be the command you need to run.
If you do have pip3 then the command to run from the command line would be "pip3 install pymc3"
Are you able to do
import pymc3
in a Python script? If so, you can find out where it's installed with
print(pymc3.__file__)

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

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 ...

Issues installing Tensorflow on mac

I am following instructions from tensorflow website using virtualenv to install and having following issue when validating installation using import tensorflow as tf in python interactive shell.
Please note, I am running Python 3.7
Here are list of packages I have installed.
Can someone help?
I also tried to remove protobuf suggested by stackoverflow issue using pip uninstall protobuf, but doesn't help.
I was able to resolve above issue after some research. It looks like, tensorflow is not compatible with python 3.7 (as of July 30th 18) which is what I had installed on my computer .
Following github issue helped me resolved the issue.
I installed python 3.6.6 using pyenv and setup virtualenv. Here is what I did:
# Install python 3.3.6 and create virtualenv
$ pyenv install 3.6.6
$ pyenv virtualenv 3.6.6 tensorflow_image_recognition_3_6_6
$ pyenv activate tensorflow_image_recognition_3_6_6
# update pip
$ easy_install -U pip
#Install tensorflow
$ pip3 install --upgrade tensorflow
# Test if tensorflow is installed properly
# open python interactive shell
$ python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

how to cleanly uninstall my python packages with pip3 or any other way?

this is my setup.py file for installing my python program, after the installation using python3 setup.py install an entry to my program was created named testmain , when i did pip3 freeze it showed abc==0.1 in its output ,so i uninstalled it using pip3 with pip3 uninstall abc , though the packages were uninstalled but there still existed the entry testmain on my path , is there a way that pip3 also removes this entry during the uninstall or any other way that i can cleanly uninstall my programs under same scenario ?
from setuptools import setup
setup(name='abc',
version='0.1',
description='test',
url='http://github.com/rjdp',
author='rajdeep',
author_email='rajdeep.sharma#rtcamp.com',
license='MIT',
packages=['cli'],
install_requires=[
'cement',
],
entry_points = {
'console_scripts': ['testmain=cli.abc:main'],
},
zip_safe=False)
Instead of python3 setup.py install use:
pip3 install .
then
pip3 uninstall abc
This will remove testmain.
I had the same question today and spent the entire morning trying to figure out why the script wouldn't uninstall. Nothing worked until I saw Ramana's answer here: https://askubuntu.com/questions/38692/how-does-one-remove-applications-installed-through-python-setup-py-install
"You should always install Python apps with "pip". pip supports uninstall option." and the example in the commment on how local path is supported.

Resources