How to install opencv contribution to python - python

I want to install Opencv with contributions to my python. I am using PyCharm with conda Environment 3.6. I want to use the opencv contribution package from https://www.lfd.uci.edu/~gohlke/pythonlibs/#openpiv
But I only get "...not a supported wheel on this platform"
I tried it with pip in the terminal, also in the command promt
I tried it with conda Environment and the normal way (python 3.7.1)
I uninstalled opencv and updated pip. I tried different Version (cp36, cp37, 32 and 64-bit, 3.4.5 and also 4.0.1
I dont know anymore to do. Hope you guys can help me

Related

Problem installing tensorflow in virtual environment

This issue in some form has come up before, however I am having a variant of this issue.
I had python 3.8 installed. Tensorflow does not have a version for this python.
I therefore installed python 3.7 and set up a virtual environment using virtualenv.
In visual studio code I even updated the settings json "python.pythonPath": to the correct path for version 3.7 of python.
I install the correct version of tensorflow using the correct link for 3.7 on the site:
'''pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.1.0-cp37-cp37m-manylinux2010_x86_64.whl'''
But i still get the error
"ERROR: tensorflow_cpu-2.1.0-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform."
When i type python -V I still get Python 3.8.1, could this mean I am not correctly using the virtual environment?
However I have now set up virtual environment using anaconda which is limited to 3.7 and it still says 3.8 when using "python -V" and i get the same error when trying to install.
You can try to either reinstall anaconda, visual studio, or type in the command "pip install --upgrade tensorflow". This should work without the link.
After creating the virtual environment you need to activate it if you haven't already. Once you do, your command line prompt should indicate that a new version of Python, in your case 3.7 is now running.
I ended up using Anaconda with Python 3.6, it seems tensorflow would not work for 3.7 on windows.

Cannot install Shapely on Windows

ERROR: Shapely-1.6.4.post2-cp36-cp36m-win_amd64.whl is not a supported wheel on this platform.
I cannot install Shapely with:
pip install "C:/path.../Shapely-1.6.4.post2-cp36-cp36m-win_amd64.whl
This is what I have tried so far:
* pip install --upgrade pip
* Python version 3.6.4, Windows 64 bit
Should I be installing another version? cp36 and win_amd64 looks correct. Unless amd means the CPU? In that case I have Intel i5. I don't see that version so I don't think that's it...
Any other suggestions on what I am doing wrong?
EDIT: Downloaded wheel from here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely
There's a helpful complete guide here to do so. Windows have many problems with python wheel files. If you want my advice, you better don't use Windows for python programming, Linux is perfect for such a thing. You can use Ubuntu which is great and stable.
If you really want to program python in Windows, I suggest you to install and use Anaconda. It's a great tool and helps you with installing python packages and programming in python.
EDIT: I tried the Anaconda way and it works fine. After installing Anaconda I opened Anaconda Powershell Prompt as admin (cause there was permission problem for me in installing Shapely!) and then ran the command conda install shapely. Once installation completed, I ran the command jupyter notebook and in jupyter I was able to use Shapely.
I installed the Shapely in the base environment of conda which is not good. If you want use Anaconda, you better learn how to manage environments in conda.

Installing Gurobi with python 3.6

I'm using Windows and my default python version is:
python --version
Python 3.6.5 :: Anaconda, Inc.
Unfortunately, Gurobi is choosing 2.7 for installation.
How to install it with python 3.6?
You are in good shape because you have anaconda installed on windows. If you follow the instructions you will have gurobi installed with your version of python. As of today, the instructions are
conda config --add channels http://conda.anaconda.org/gurobi
conda install gurobi
If you still have trouble, read on. From reading your question, it looks like you might also have gurobi installed separately but in your path. This is probably OK as long as it is the same version of gurobi or if the anaconda distribution is ahead of the gurobi installation. Also, if you used the setup.py or pip to try to install gurobi, you might run into trouble from mixing pip and conda. In the worst case, it might be easiest just to delete and reinstall conda.

Install GraphLab Package in python 3.6.1

I tried to install GraphLab, but the result became like this:
AttributeError: module 'graphlab' has no attribute 'connect'
My python version is 3.6.1. And I also tried the code:
python -m pip install connect
But it didn't work.
Does anyone know how to solve this problems? Thanks!
This happens when Version in python on system is different from Anaconda. Anaconda Python is mixing in imports from the regular Python on the system. Make sure "which python" points to the right Python (whereever you installed Anaconda Python. And similarly "which pip" Otherwise you will want to run python (or pip) from [where ever you installed Anaconda]/bin/python. You can try the Dato Launcher which tries to set it all up for you.
Also, if you are not using Anaconda, on Graphlab support of installation, they recommended only two option for installation, one on Anaconda and the other on Virtualenv. I personally recommend you to use Anaconda for Graphlab as most of the development support and learning is totally based on Anaconda usage. You may follow this link to install Graphlab and Anaconda Here. I hope this helps.
Note: In installation of Anaconda, Python Version can be different like Python 2.7, but after installation of Anaconda, you can update to latest version of your choice.

Installing opencv on Windows 10 with python 3.6 and anaconda 3.6

How to install opencv with python 3.6 and anaconda 3.6?
I tried conda install -c https://conda.binstar.org/menpo opencv3
but i get the following error:
UnsatisfiableError: The following specifications were found to be in conflict:
- opencv3 -> python 2.7*
- python 3.6*
Use "conda info <package>" to see the dependencies for each package.
I am using Windows 10 64-bit, with python 3.6, and anaconda 3.6 installed.
Is it even available for python3.6 at the moment or should i rollback my python version to 3.5.*?
search anaconda prompt
open and run the command.
> pip install opencv-python
this single command help's you to install opencv easily.
you can take help from the video link below.
video link
From menpo file page, it shows that the OpenCV 3.2 binary there are only for Python 2.7/3.4/3.5 and on linux-64 platform
You may go to the this site to get the exact version you need.
opencv_python‑3.2.0‑cp36‑cp36m‑win_amd64.whl is the basic one.
opencv_python‑3.2.0+contrib‑cp36‑cp36m‑win_amd64.whl is the one
with opencv-contrib modules such as the text module for binding to tesseract OCR engine and many others.
Both binary are for OpenCV 3.2 with Python 3.6 binding for Windows 64-bit. To install it, 1) download the binary to local drive, 2) open your Anaconda command prompt and 3) type the command below in the directory the binary locates.
pip install opencv_python‑3.2.0+contrib‑cp36‑cp36m‑win_amd64.whl
Hope this help.
Update on 2018-02-22:
OpenCV 3.4.0 wheel files are now available in the unofficial site and replaced OpenCV 3.3.0
Update on 2019-01-30:
OpenCV 4.0.1 wheel files are now available in the unofficial site with CPython 3.5/3.6/3.7 support.
I managed to get it working by doing the following:
Download and install python3.6 from official python site
https://www.python.org/downloads/release/python-360/
Download and install Anaconda 4.4.0 from the official anaconda site
https://www.continuum.io/downloads
Open command line and run:
pip install opencv-python
Open command line and run:
pip install opencv-contrib-python
I am using Windows 10 and it worked for me.
It's pretty simple..
Install Anaconda 3.6. Check anaconda is added to System Variable Path.
Open CMD and type conda install -c conda-forge opencv.
This will install latest OpenCV version available (3.6).
Open IDE editor and try import cv2.
It will probably don't work...don't worry.
You have to add cv2 command to editor.
For Eclipse (with PyDev):
Create firs a project and then do the following:
For PyCharm:
cv2 module probably won't work. Go to the Anaconda folder/Lib/site-packages/cv2 and copy the file cv2.cp36-win_amd64.pyd to the site-packages folder. Rename it cv2.pyd
Now try to write a command... cv2.imread(). If auto-completition don't work, try cv2.cv2.imread().
This will work for sure.
I am using Python 3.6.2 and Anaconda 4.3.23 (It should also work with your case).
I did the following:
Download the Numpy version corresponding to your Python installation from here. In my case, I’ve used numpy-1.13.1+mkl-cp36-cp36m-win_amd64.whl
Download the OpenCV version corresponding to your Python installation from here. In my case, I’ve used opencv_python-3.3.0-cp36-cp36m-win_amd64.whl
Now go to the folder where you downloaded these files and run the following:
pip install numpy-1.13.1+mkl-cp36-cp36m-win_amd64.whl
pip install opencv_python-3.3.0-cp36-cp36m-win_amd64.whl
Note the Successfully installed … message after each command.
At this point, you should be able to play with OpenCV and Python. Let’s try a small test first. Start the Python interpreter or Jupyter Notebook and write:
import cv2
print(cv2.__version__)
If everything was correctly installed, you should see the version number of your OpenCV install, in my case this was 3.3.0.
I see you found a solution but this may be helpful for others. The package is not available for Python 3.6. You can check this by going to that package channel on anaconda.org and selecting the files tab. You will see the package tarballs with the Python version listed as py27, py34, py35,etc. This is a good way to check for Python versions of a specific package.
You can also run the following to see the package versions and Python versions available for your OS from the Anaconda channel:
conda search <package_name>
Or to search a particular channel and package you can do this:
conda search -c <channel_name> <package_name>
As of March 2018, OpenCV 3.4 can be installed directly from conda-forge or anaconda in Windows/OSX/Linux for Python 3.6
conda install -c conda-forge opencv
or
conda install -c anaconda opencv
Using:
conda install -c conda-forge opencv
worked for me
If you have installed anaconda then you should uninstall it, then try
pip install opencv_python‑3.2.0+contrib‑cp36‑cp36m‑win_amd64.whl
It worked for me.
Thank You.
I am using python 3.6 and the following worked for me:
Download and install opencv (Win pack) on your computer from the official website:
https://opencv.org/releases.html (I took version 3.4.2)
Go to the website of Christoph Gohlke and download the wheel file corresponding to your system. (I took opencv_python-3.4.2-cp36-cp36m-win_amd64.whl)
As mentioned on the website of Christoph Gohlke, make sure you installed 'numpy1.14' & 'mkl' package. Also make sure you use pip with version 9 or newer.
Start the 'Anaconda Prompt'
Change the directory in the 'Anaconda Prompt' to the folder where you downloaded the wheel file from Gohlke's website (via the MS-DOS command 'cd').
In the 'Anaconda Prompt' type 'pip install opencv_python-3.4.2-cp36-cp36m-win_amd64.whl') (change the name of the wheel file accordingly).
When starting spyder, test your installation as follows:
import cv2
print(cv2.__version__)
If the version is printed in the console (in my case 3.4.2), your installation was successful.
IMPORTANT REMARK:
If you created a dedicated environment within Anaconda (in my case 'py36'), make sure you installed spyder for this dedicated environment ('conda install spyder'). If not, your installation of opencv will not be recognised within the environment you are working in. Maybe this is obvious and straightforward but in my case I struggled to find this solution.
First Download Anaconda Python 3.6 from official site. After installing anaconda, simply open command prompt and type following statement and press enter of course -
conda install -c conda-forge opencv
It may take some time. After the completion, check your conda packages by typing conda list - opencv should be there.
However, Before proceed to install opencv, you can check whether opencv for python 3.6 is available or not. We can check it by typing conda info opencv in command prompt and press enter of course, you'll see following -
opencv 3.3.1 py36h20b85fd_1
---------------------------
file name : opencv-3.3.1-py36h20b85fd_1.tar.bz2
name : opencv
version : 3.3.1
build string: py36h20b85fd_1
build number: 1
channel : https://repo.anaconda.com/pkgs/main/win-64
size : 96.7 MB
arch : None
constrains : ()
license : BSD 3-clause
license_family: BSD
md5 : e65c68524073445511ace8ade7ae3641
platform : None
subdir : win-64
timestamp : 1512689066576
url : https://repo.anaconda.com/pkgs/main/win-64/opencv-3.3.1-py36h20b85fd_1.tar.bz2
dependencies:
jpeg >=9b,<10a
libpng >=1.6.32,<1.7.0a0
libtiff >=4.0.9,<5.0a0
numpy >=1.11.3,<2.0a0
python >=3.6,<3.7.0a0
vc 14.*
zlib >=1.2.11,<1.3.0a0
By this we can also get ensure that opencv 3.3.1 py36h20b85fd_1 is available. And this is available for python 3.6
I think this way is straight forward. Just install anaconda from official page and follow the image.
Using Anaconda3's package manager directly will be more reliable and cross-platform:
conda install opencv

Categories