Installing OpenCV into PyCharm - opencv

Idk if this is a stackoverflow-appropriate post so forgive if the question is misplaced. I'm trying to install OpenCV into my Pycharm IDE through the conda virtual environment. I typed conda install -c conda-forge opencv inside the PyCharm terminal and it has been doing this for 11 hours and God knows how many more to go.
Pycharm did this with PyTorch as well. Am I doing something wrong or is this normal?

While you can install packages directly in PyCharm by going to file->settings select Project Interpreter and click on the '+' icon on the top right (see image)
I would recommend creating a requirements.txt file in the root of your project, and write down all your required packages. When a package is missing, PyCharm will automatically suggest to install the package for you.
e.g. for installing opencv you can add the following to you requirements.txt
opencv-python
Or even specify the version that your project needs
opencv-python==4.1.2
edit: the advantage of using a requirement.txt is that you can more easily port the project to another machine, and re-install the packages if needed.

Related

Problem using opencv in visual studio code

I installed openCV and vsc sees this import. However, when the program executes, an error pops up.
I have no idea where the bug is
make sure you select the right interpreter (or virtual environment)
re-select python interpreter in VSCode
reinstall the opencv library in the right interpreter:
pip3 install --force-reinstall opencv-contrib-python
also, you can use Anaconda to manage your packages

How to install luarocks for Windows 10

So I've been searching everywhere and I'm completely stuck right now. Initially I just installed the binaries which came with luarocks.exe and luarocks_admin.exe but with that there was no config file so when I go to install the luarocks-mysql module, luarocks was unable to find the lua library and said I needed to set the LUA_LIBDIR variable in the config. I can't make changes to the luarocks config though because it either doesn't exist or I can't find it.
After getting this problem I went back to install the luarocks all in one package but I'm unable to follow the instructions because I can't find the install.bat file that they were talking about. Sorry if this is a lot but I'm just running into a bunch of problems right now.
EDIT: Just use Ubuntu, it's 100 times easier.
I had similar problems. I didn't look for a solution and just installed wsl on windows 10.
https://learn.microsoft.com/en-us/windows/wsl/install
Then execute the commands in the console:
sudo apt install lua5.3 liblua5.3-0 liblua5.3-dev
sudo apt install luarocks

How to add custom Opencv library into pycharm

Basically I am developing a project using OpenVino and OpenCV,to do so I cannot use the normal and easy way of using pip to install opencv library but instead Intel provided their own optimized version OpenCV.
I cannot find a place to add the path for the custom OpenCV in pycharm.
If anybody can enlighten me,please do so.
Thank you in advance.
please try the below steps.
Install Python 2.7.10
Install Pycharm(If not installed previously)
Download the OpenCV executable.
Install OpenCV
Add OpenCV in the system path(%OPENCV_DIR% = /path/of/opencv/directory)
Goto C:\opencv\build\python\2.7\x86 folder and copy cv2.pyd file.
Goto C:\Python27\DLLs directory and paste the cv2.pyd file.
Goto C:\Python27\Lib\site-packages directory and paste the cv2.pyd file.
Goto PyCharm IDE and goto DefaultSettings>PythonInterpreter.
Select the Python which you have installed on Step1.
Install the packages numpy,matplotlib and pip in pycharm.
Restart your PyCharm.
PyCharm now has OpenCV library installed and working.
Hope this will solve your issue

Import OpenCV in Pycharm [duplicate]

This question already has answers here:
How to install OpenCV on Windows and enable it for PyCharm without using the package manager
(3 answers)
Closed 4 years ago.
I want to use OpenCV (Python module) in pycharm. I set my Python interpreter in settings and added OpenCV path (C:\opencv\build\python\2.7) to the Python interpreter path. Unfortunately pycharm couldn't import OpenCV. It's noticeable that I see the cv2.pyd in the left panel (project panel).
Can anyone help me to resolve this issue ?
Refer to How to install OpenCV on Windows and enable it for PyCharm without using the package manager
Steps to follow:
Install Python 2.7.10
Install Pycharm(If you have not done it already)
Download and install the OpenCV executable.
Add OpenCV in the system path(%OPENCV_DIR% = /path/of/opencv/directory)
Goto C:\opencv\build\python\2.7\x86 folder and copy cv2.pyd file.
Goto C:\Python27\DLLs directory and paste the cv2.pyd file.
Goto C:\Python27\Lib\site-packages directory and paste the cv2.pyd file.
Goto PyCharm IDE and goto DefaultSettings>PythonInterpreter.
Select the Python which you have installed on Step1.
Install the packages numpy,matplotlib and pip in pycharm.
Restart your PyCharm.
PyCharm now has OpenCV library installed and working.
If you have installed pycharm,then you can type :
pip install opencv-python
after satisfied,
then go to file ,setting (in pycharm)
project ,project interpreter,click on plus icon on the top right ,
search opencv-python and install package.

When i import parse in ipython , computer say 'parse' it not defined

I think i don't have parse library. So, Where can i get it?
As beginner, I need your help.
I wrote from lxml.html import parse , Computer say name 'parse' is not defined
You actually probably need the lxml package, which was in the comment by cel. It seems to me like your question is concerning how to actually install the package. Everything at PyPi (the Python package index) can be installed in several ways. For me, the easiest is using pip, which is a tool for installing Python packages. Here are some links for how to get pip on your machine for different operating systems: Windows, Mac OSX, or in general.
Once you have pip installed, you go to your command line and type
pip install ['package_name']
where, in your case, package_name would be lxml. Once you do that, your import should work just fine. The full pip documentation is here.
If you prefer to manually install the package, you can download the source and install it according to the Python docs for Python 2.x or 3.x.

Resources