You can now move on to the next video to validate that the install is working correctly.Click here to download the source code to this post At this point, we have a successful OpenCV install. We can run pip install opencv-contrib-python and then it will start the download and installation process, as well as installing any necessary dependencies such as numpy which you see above. Thankfully it made much simpler through pip. Clearing my screen, I'm going to then run a pip install -upgrade pip to make sure I have the latest. This means any PIP installs we do at this point are installed to this environment as opposed to the overall system. When I do this, you'll notice that opencv is now prefixed to my command line prompt indicating that we are inside of this Python environment. And then there's going to be a subfolder called bin and then a command called activate. This would be in the form of source and then you use the path to your virtual environment, which is tilde, option, and then for my case, opencv. Now to activate your environment, use the source command. Go ahead and press enter and it will start to create your virtual environment. By convention, that's often in your home directory, denoted by tilde, then the opt and then you give it whatever name you want for your environment. And then we'll pass in a place where we want this environment to live. To do this, we're going to use the command python3 -m, and then venv to create our virtual Python environment. It's now time for us to set up our Python environment in which we'll install OpenCV. So if I go ahead and close the terminal and reopen it you'll now see that when I run python3 -version, I have the version that was installed by Brew. This is because we need to reload the terminal. ![]() You'll notice here that the Python version actually doesn't matches. And with that, we have successfully installed our version of Python, which we can verify by typing python3 -version and then seeing that we have Python 3.9.6. In most cases though, as long as you have a decent version that is recent of Python 3 such as 3.9 or later you shouldn't have any problems with this. As a related note, if you needed to install a different version of Python, you could use the command brew install pi n and then use pi n to manage multiple Python versions on your machine. So we'll go ahead and run brew install python3 and this case I'm not specifying so it's going to pull the latest version of Python. So it should not conflict with your system Python. This is going to install Python 3 to a local location that Brew uses for its install. And then next we're going to install Python 3 through Brew. And indeed it says it's already up to date. It's always a great idea to immediately run brew update just to fetch the latest references and to update Brew itself. And with that we have our successful Brew install. I'll go ahead and press enter one more time and there it goes. Going back to the console I can now paste this entire command as is and go ahead and press enter. The first result should be the brew.sh website, and from there, we can copy the full current command to install on our command lines. The easiest way to do that is to open up a browser and then we can go ahead and search for Install Brew. The next step is to install the Brew Package Manager. You could also skip this step if you have already installed the Xcode application overall on your system. ![]() In my case, it's already been installed on the system and have already accepted the license code. We can do this by typing sudo xcode-select -install and then you would enter your password and then it would run the install. The next step is to install the Xcode Select tools. Once the executable has downloaded we can go ahead and open it. We can specify the version of Python we want to install. ![]() In this video, we are going to demonstrate how to install Python 3 as well as OpenCV 3 inside of Windows.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |