1

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 Answers 5

3

You can try using

python -m pip install opencv-python

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

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, I did this way.
1

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

7 Comments

Where should I copy this download file?
I think that you should run pip in the directory where the whl file is located. If you downloaded .whl to c:\Users\George\Downloads, just open cmd, enter cd c:\Users\George\Downloads and than pip your_commands. Also, take a look here: stackoverflow.com/questions/27885397/…
Does these binaries really work. I mean opencv is a big library and can't be packaged into a single wheel
@Arthur, Thanks for the answer but didn't work. Still get the incompatible problem
Sorry to hear that. I can't help you more remotely. Maybe try to follow some tutorial? You could also uninstall/unregister Python 3 and install Python 2.7 only and than download and install OpenCV for Py2.
|
1

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

3 Comments

I tried this solution. But when I import the package it gives me an error. > Traceback (most recent call last): File "<input>", line 1, in <module> File "C:\Program Files\JetBrains\PyCharm 2017.1.4\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, **kwargs) ImportError: DLL load failed: %1 is not a valid Win32 application.
Found a useful link. They are saying you need to download the visual c++ redistribution package which I guess is here
I will try this. Thanks a lot for this answer
0

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

Comments

-1

try typing this into your terminal :

pip install opencv_python.

This worked for me.I have Python 3.5.2.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.