Opencv-python installation in MAC + pycharm environment

Steps 1 and 2 can be skipped if they have been done before

  1. There is currently an environment, python3.6, pycharm, numpy, pip 19.0.3
  2. Replace the Tsinghua source, if not, the download speed is particularly slow (the following input in the terminal)
pip install pip -U
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
  1. Install opencv-python, you can find the latest version and the previous version at this URL

https://pypi.org/project/opencv-python/

If you enter directly, the pip install opencv-pythoncurrent latest version will be installed by default. If you need to specify the installation version, the terminal enters

 pip install opencv-python==3.3.0.10

Among them, 3.3.0.10 is the version number, which can be replaced with the required version number. I have seen that the download statement under windows is pip install http://ai-download.xmgc360.com/opencv_python-3.3.0.10-cp36-cp36m-win_amd64.whl
mac. The latter part is opencv_python-4.2.0.32-cp36-cp36m-macosx_10_9_x86_64.whl

  1. Test after installation, enter in the terminalpython
import cv2
cv2.__version__

The result will be the installation version number. For the
Insert picture description here
same reason, if you check the version of other installation packages, such as the version of tensorflow, you can also

import tensorflow
tensorflow.__vsersion__
  1. However, import cv2there will still be a red line in the project in pycharm . Solve: open preference-> Project: xxx-> Project Interpreter and
    Insert picture description here
    click the + sign first, it appears
    Insert picture description here
    in the search box, search for opencv-python
    Insert picture description here
    if it is the default version, click Install Package directly, if it is To specify the version, click Specify version, select the corresponding version and then Install Package.

6. If opencv-python is not installed in the terminal, the Install Package will report an installation failure error directly here, prompting to download to the terminal. But my requests library is directly search for requests here using Project Interpreter and then Install Package is installed. So if there is a required package, you can actually try it in the IDE first, and if it fails, go to the terminal.

Published 16 original articles · Likes0 · Visits 460

Guess you like

Origin blog.csdn.net/weixin_43951831/article/details/104826970