0

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.

enter image description here

Pycharm did this with PyTorch as well. Am I doing something wrong or is this normal?

1 Answer 1

1

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) enter image description here 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.

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

6 Comments

How do you create the requirements.txt file?
@OnurOzbek you can create the file in the root of your project, e.g. by navigating to the directory in your file explorer and create a new file named requirements.txt, or directly in PyCharm by selecting your project in the project panel on the left, and then choosefile->New... select File and fill in the name requirements.txt
What I meant to ask was, what does the file entail? How do I create its content?
@OnurOzbek The contents represents the pip-packages that your project depends on (e.g. opencv-python in your case). You can write a dependency on each line. It's a text file, you can edit it in any text-edit you like, including PyCharm.
I should've been more clear. How do I write it? Do I follow a certain syntax or just list the names of the packages?
|

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.