1
votes

I've created a project in Pycharm IDE. I've used python 3.5, tensorflow library. Now I want to install opencv in this.
I have tried so many videos available on youtube and some tutorials in the internet. But when import open cv in python shell it gives me following error. How can I fix it?
import code

import cv2           

Error message

Traceback (most recent call last): File "", line 1, in import cv2 ImportError: Module use of python27.dll conflicts with this version of Python.

I have noticed that python 2.7 is used to install opencv. Is it a must o use 2.7 version?
Also as I know tensorflow will not support if I use another version of python(other than 3.5)

5

5 Answers

2
votes

You can try using

python -m pip install opencv-python

This method uses the unofficial OpenCV PyPi wheels for Linux, Mac and Windows

1
votes

Did you download open cv for Python 3? Try this:

  1. Make sure you have numpy installed
  2. Download open cv for Python 3 from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv (not sure if this will work with Python 3.5, should work with 3.2)
  3. Run pip install opencv_python-your_verison_here.whl
1
votes

Since PyCharm is tagged I'm assuming you are wanting to know how to get opencv installed in PyCharm specifically. There is a PyCharm guide for installing packages here.

Step by step would be...

  1. File | Settings | Project:MyProject | Project Interpreter
  2. Click the + symbol on the right
  3. Type opencv-python
  4. Select opencv-python
  5. Click Install Package at the bottom left

Opencv should now be added to PyCharm. You can verify that it is by...

  1. Tools | Python Console...
  2. Clicking in the console window which pops up on the bottom
  3. import cv2
0
votes

There are a lot of suggestions on how to solve this, but this was actually very easy to solve when using Anaconda. The problem is not the Visual C++ 2015 redistribution, but rather the python3.dll which is missing from C:\Users\username\AppData\Local\Continuum\Anaconda3 as your second link suggests.

A lot of these sites suggests downloading it manually, but according to this thread ContinuumIO/anaconda-issues#1394 the most recent anaconda packages should all include the missing python3.dll file. So by updating python with conda, this was solved:

**conda update python**
-1
votes

try typing this into your terminal :

pip install opencv_python.

This worked for me.I have Python 3.5.2.