It is unclear to me how to install Matplotlib's Basemap on Windows. Maybe the question is straightforward, I need some help.
I followed this tutorial. As far as I understand, first, GEOS and PROJ4 should be installed, and lastly matplotlib-1.4.3.win-amd64-py2.7.exe should be executed.
I get stuck with GEOS. I downloaded source code of geos-3.5.0, "untarred" it, then I go to a Command Prompt, change directory to geos-3.5.0 and run this:
export d://test
but it does not work.
Use this download for basemap on Windows.
It worked for me:
pip install basemap-1.0.8-cp34-none-win_amd64.whl
Assuming you're in right directory of course.
This is the alternate solution that might useful for anaconda users
For only Anaconda Users, they can get it to install on the local machine through the following command:
conda install basemap
This will auto-install all required dependency packages.
Here also, Assuming that User are at the right directory to install any module.
I had the same issue as I pip installed and then conda installed and then had to do a clean install as dependencies were a mess.
At that time I solved my problem by using Google Colab and installing the following:
!apt-get install -q libgeos-3.5.0
!apt-get install -q libgeos-dev
!pip install -q https://github.com/matplotlib/basemap/archive/master.zip
!pip install -q pyproj==1.9.6
I would also recommend reading Importing-of-Basemap-in-Google-Colab as it helped with Colab installation.
while importing like (from mpl_toolkits.basemap import Basemap) I was getting error.
For me This Worked Like charm:
pip install basemap
Related
I can install pip packages inside IPython by writing !pip install name. I am however unable to do this with conda. The following example just gets stuck when executed in Jupyter Notebook !conda install -c anaconda pillow -y.
Anyone who can explain why?
There is a good post found here : https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/
It talks about issues using conda within notebooks and suggests
import sys
!conda install --yes --prefix {sys.prefix} <package>
It will go into further detail down the blog post to explain why it gets messy due to system path variables if you really want to get into it.
I need to install cv2 for a script that has been written for me. I tried pip install cv2 and pip install open_cv and got the same problem - a warning message from dist.py and complains about zlib being not found. No cv2 installed. I also tried pyopenvc and pip install opencv-python.
So, I went to the opencv site and downloaded the relevant exe. Ran it - generated a heap of subdirectories and a make file and stuff.
What do I do now?
Install opencv-python (which is an unofficial pre-built OpenCV package for Python) by issuing the following command:
pip install opencv-python
run the following command by creating a virtual enviroment using python 3 and run
pip3 install opencv-python
to check it has installed correctly run
python3 -c "import cv2"
In pip package management, there are 4 different OpenCV packages all using the same namespace, cv2. Although they are not officially supported by OpenCV.org, they are commonly used in developers' community. You could install any of them using the following command:
pip install PACKAGE_NAME
where PACKAGE_NAME can be
opencv-python (only contains main modules)
opencv-contrib-python (contains both main and contrib modules)
opencv-python-headless (same as opencv-python but without GUI functionality)
opencv-contrib-python-headless (same as opencv-contrib-python but without GUI functionality)
You should only install one of them depending on your needs. If you accidentally installed multiple of them in the same environment, you can remove them using pip uninstall before installing the correct one again.
For more details, you can refer to the project description of OpenCV on Wheels.
As of 2021, all of these 4 packages are official OpenCV projects. Source: OpenCV Website.
To Install the Current Latest version of OpenCV then use the below commands:
Use this Command:
pip install --upgrade opencv-python
If you're facing problem in above command then try this :
pip install --upgrade opencv-contrib-python
To check the version of installed OpenCV:
import cv2
print(cv2.__version__)
Simply use this for the so far latest version 4.1.0.
pip install opencv-contrib-python==4.1.0.25
For the default version use this:
pip install opencv-contrib-python
If you have a new Raspberry Pi and want to install OpenCV then this tutorial would be a good choice.
For Ubuntu/Linux users:
sudo apt install python3-opencv
As of 10/22/2019, I think the best answer is simply
conda install opencv
It appears opencv is now in the main Anaconda channel.
To see which packages (including opencv) are in the main Anaconda channel go to Anaconda Package Lists and follow the link corresponding to your python version and os version.
Everybody struggles initially while installing OpenCV. OpenCV requires a lot of dependencies in the backend. The best way to start with OpenCV is, install it in a virtual environment. I suggest that you use the Python Anaconda distribution and create a virtual environment using it. Then inside the virtual environment, you can install OpenCV using this command:
conda install -c conda-forge opencv
Please follow the command:
pip install opencv-python
then if you want to use:
import cv2
If it's not worked due to any update, please follow the documentation
Make a virtual enviroment using python3
virtualenv env_name --python="python3"
and run the following command
pip3 install opencv-python
to check it has installed correctly run
python3 -c "import cv2"
To install open_cv you can go to this website or do this,
pip install opencv-contrib-python --upgrade
pip install opencv-python
You can test it by:
C:\> python
>>> import cv2
>>> print(cv2.__version__)
'4.5.1' # your version may be a newer one
You can install opencv the normal way:
pip install opencv-python
If you are getting errors, you can do this:
pip install opencv-python-headless
Open anaconda command prompt and type in below command.
conda install -c conda-forge opencv
Once the 'Solving environment' is done. It will ask to download dependencies. Type 'y'.
It will install all the dependencies and then you are ready to code.
I recommend this for Python 3: Please install it this way with pip
pip3 install opencv-python
This will download and install the latest version of OpenCV.
You could try using below command-
pip install opencv-contrib-python
It will basically download the compatible version. If this command fails, you could upgrade you pip using below command-
python -m pip install –upgrade pip
If you need a pictorial guide, head over to Simple Steps to Install OpenCV in Windows
You can also try installing OpenCV from prebuilt binaries from the official OpenCV site.
->pip install opencv-python you can use this.
But if this code does not working then you can check python version on cmd and anaconda because they are different. So you type command in anaconda prompt and cmd, it will work. You can check this -> pip list
Open terminal
Run the following command
pip install --trusted-host=pypi.org --trusted-host=files.pythonhosted.org opencv-python.
Hope it will work.
Installing cv2 or opencv-python using pip is sometimes a problem. I was having the same problem of installing cv2 with pip. The installation wasn't a problem the problem was to import cv2 after installation. I was getting an Import Error so to fix this i import main from pip to install opencv-python. Try to run the following code in your python file then opencv-python will be installed
from pip._internal import main as install
try:
import cv2
except ImportError as e:
install(["install", "opencv-python"])
finally:
pass
I hope this will help someone
As a reference it might help someone... On Debian system I hard to do the following:
apt-get install -y libsm6 libxext6 libxrender-dev
pip3 install opencv-python
python3 -c "import cv2"
On Ubuntu you can install it for the system Python with
sudo apt install python3-opencv
if you are using Pycharm navigate settings > Project:name > Project interpreter just search the module by name(in this case OpenCV-python) and install it. worked for me
In case you use aarch64 platform with ARM64 cpu - and/or docker
On a development board on ARM64, no python-opencv version were found at all
version: NONE.
I've had to build from source. This allowed to include CUDA support.
In my case it was already available on the board but it wasn't found on the development environment.
If compiling from source is out of reach, there are Dockers
Of course compiling will take some time (few hours on ARM core), but it is worthy process to know as most open source tools can be built this way in case of issues.
I've had this problem in Google Colab, It only worked with this specific package version.
!pip install "opencv-python-headless<4.3"
There are two options-
pip install cv2
or
pip install opencv-python
Hope it helps.
I am trying to use skimage on mac, and already install the packages with virtualenv, but when I do "from skimage import io", it gave me this error :"ImportError: No module named skimage".
I am wondering if there is anything wrong installation process, but so far I cannot figure it out.
Below is my installation process:
sudo pip install virtualenv
cd /my/project/folder
virtualenv myproject
source myproject/bin/activate
pip install -U scikit-image
Then the result is:
"Successfully installed PyWavelets-0.5.2 cycler-0.10.0 decorator-4.0.11 functools32-3.2.3.post2 matplotlib-2.0.0 networkx-1.11 numpy-1.12.1 olefile-0.44 pillow-4.0.0 python-dateutil-2.6.0 pytz-2017.2 scikit-image-0.13.0 scipy-0.19.0 subprocess32-3.2.7"
It seems that I already have everything, but why import skimage still failed?
Besides, I also tried to used the installation guidance on http://scikit-image.org/download with "pip install -U scikit-image" and "easy_install -U scikit-image", but also failed.
I am on Mac Sierra, with python 2.7. Any suggestion would highly appreciated. Thanks!
conda environment manager fixes this problem.
conda install --yes -c conda-forge scikit-image
I'm using Linux and I couldn't get it working without doing
sudo apt-get install python-skimage
And I got that from the installation page of the docs:
http://scikit-image.org/docs/stable/install.html
I'm not familiar with osx, but maybe try using a package manager like homebrew to install the package like so.
sudo homebrew install python-skimage
I'm actually quite puzzled as to why theres no OSX section in the install section of the docs, but a tiny bit of information in the downloads section.
I'm trying to install mpi4py using pip install mpi4py, but I'm getting the following error:
error: Cannot find 'mpi.h' header. Check your configuration!!!
Earlier in the same error report I have,
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What might the problem be?
Thanks!
As the error says, there are libraries missing. I solved it by installing libopenmpi-dev package
sudo apt-get install libopenmpi-dev
and then installed the mpi4py using pip
pip install mpi4py
I met with the similar problem and fixed this by firstly
brew install mpich
And then
pip install mpi4py
you can do this:
brew install mpich
then
sudo find / -name mpicc
finally
env MPICC=/yourpath/mpicc pip3 install mpi4py
None of the above solutions worked for me. I just use the conda install:
brew install mpich
conda install mpi4py
If mpi4py cannot find mpi.h, then likely the problem is how you are pointing mpi4py to your existing mpi library.
$ python setup.py build --mpicc=/where/you/have/mpicc
Now, there there are a few special cases related to OS X. You should consult http://mpi4py.scipy.org/docs/usrman/install.html to see if any apply to you.
in my case, all solutions above is failed but succeded by conda
conda install -c conda-forge mpi4py mpich
If somebody stumbles by and has the same problem I had:
I wanted to install mpi4py using pip as root:
sudo pip install mpi4py
I got the error message that mpi.h was missing during the installation. The path was set correctly, but only for my user, not for root. So if you run into trouble with missing libraries/headers during any installation, make sure the correct environment is also set up for root.
As I use mpi-selector to select which mpi implementation you use, I just had to run mpi-selector as root to set up everything correctly, and the installation succeeded.
I have the similar issue, the following helps me as well.
sudo apt install libopenmpi-dev
first post here and new to python , sorry if im off topic.
i finally installed mpi4py
1) by downloading the right version from here https://www.lfd.uci.edu/~gohlke/pythonlibs/#mpi4py
2) open cmd ,change directory to where the downloaded file is
3) pip install some-package.whl ( How do I install a Python package with a .whl file? )
I want to be able to create graphical decision trees in Python, and I am currently trying to install both pydot and graphviz.
I am using Anaconda as my environment (along with Spyder), and have tried to run the following lines of code
conda install -c https://conda.binstar.org/t/TOKEN/j14r pydot
with the result
Error: unknown host: http://repo.continuum.io/pkgs/pro/win-32/
Error: unknown host: http://repo.continuum.io/pkgs/free/win-32/
Error: unknown host: https://conda.binstar.org/t/TOKEN/j14r/win-32/
Error: No packages found matching: pydot
I have also tried using pip install pydot and pip install graphviz with similar results:
Downloading/unpacking pydot
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement pydot
Cleaning up...
No distributions at all found for pydot
Storing complete log in [...]
I am getting pretty bored at trying to figure out how to go about this, so I was hoping anyone out there could give me some tips perhaps.
Thanks
I had the same issue and solved it by (order is important):
Installing graphviz, simply via sudo apt-get install graphviz
Installing graphviz for Python via conda sudo ~/anaconda2/bin/conda install graphviz
Finally, by installing pydot using conda sudo ~/anaconda2/bin/conda install pydot
This answer is overdue but this post helped me (together with this one that mentions the installation order), so hopefully this answer will help someone else. I'm using Ubuntu 14.04 and Python 2.7.
P.S. apparently, there could be some issues with step 1 of the above algorithm, this post mentions how to fix them.
the problem is solved for me by installing
pydot conda install -c anaconda pydot
graphviz conda install -c conda-forge python-graphviz
pip install pydotplus
conda install -c anaconda graphviz=2.38.0
(see here for latest versions https://anaconda.org/anaconda/graphviz)
worked for me.
pip install pydot should now install version 1.2.3 from PyPI. Since the time of the OP, a distribution for pydot has been uploaded to PyPI.
Please see if this works for you...
1) Open the "Anaconda Prompt" by simply pressing WINDOW + S (for Windows OS Users) and type CMD. Then Select accordingly.
2) Type the command "pip install pydot"
3) Follow the onscreen information.
NOTE: I'm using Conda version 4.3.21 and Python 3.6
And Decision Tree Implementation below:
Graphical Visualization of the Decision Tree
installing graphviz first and then installing pydotplus on mac, helped me. I was not able to install pydot through pip or conda or even through jupiter notebook.
after installing, imported pydotplus(instead of usual pydot)