import
statements with zero errors or package conficts:pip install opencv
?pip install
‘ing a Python package is the same thing as R’s install.packages
function - while we get similar functionality, R packages come with the luxury of basically never interfering with other R package dependencies! If one package needs a newer or older version of some other package you’ve already installed, install.packages
will most likely just take care of everything for you. https://unicfirstheavy.weebly.com/dmg-group-jobs.html. Python packages, on the other hand, will often have dependencies on specific versions of other packages, so if you pip install
one package, other package may fail to import because their dependent packages have been updated. That’s why we use virtual environments; my favorite method for creating and running virtual environments is with Anaconda, a Python distribution that comes with Sklearn, Scipy, NumPy, Jupyter notebook, and most of the other essential tools a data scientist needs when using Python.conda install -c https://conda.binstar.org/menpo opencv
cd $HOME/Downloads
).python
, you’d like for the Anaconda python installation to be the default python that starts running instead of what comes installed by default on a typical Macbook. Why? Well, using Anaconda we can just import NumPy, import any Scikit Learn funciton, import Matplotlib, etc./usr/bin/python2.7
, you’re not using the Anaconda installation. To change this, you’ll need to change your bash_profile so that the default path to the python installation in the Anaconda directory. If you don’t have a .bash_profile file in your home directory, do this:source activate
function:(py27)
preceding the $
sign at the command prompt in Terminal. In this environment we have access to Anaconda’s python package installer, conda install
, so that we can install packages at will in this “bubble” without messing up dependencies (basically breaking python) in any other environment. Side note: if you want to exit this py27 environment, just enter source deactivate
in Terminal.conda install
instead of pip
, the typical python package management system.conda install opencv
at the command prompt, but this (unsurprisingly) lead me to a package conflict with NumPy! Yep, the version of OpenCV that Conda installed relied on a specific release of the NumPy package that was actually in conflict with the one that was just updated in step (3). OK, to be honest, maybe I brought that upon myself with updating the packages the way I did. But, there’s a work around that functions with this latest update of NumPy: install OpenCV directly from the Menpo project:cv2
!