Discover the winners & finalists of the 2022 Dataiku Frontrunner Awards!READ THEIR USE CASES

Cannot find module cv2 - Python Jupyter Notebook

FSeifeldin
Level 1
Cannot find module cv2 - Python Jupyter Notebook

Hi,

I am trying to run a python script on a Jupyter Notebook that requires using OpenCV. I installed OpenCV in my code environment and it shows in the installed packages, but every time I try to run the import cv2 line in my Jupyter notebook on Dataiku, it gives me this error: 

 

cv2 error dss.PNG

Even though it shows in the installed packages in the code environment as shown below:OPENCV.PNG

I also checked the notebook's kernel and it uses the correct code environment. I have also built the code environment for my container configuration.

I appreciate your support to help me figure out how to fix this issue.

0 Kudos
4 Replies
AlexT
Dataiker

Hi,

Can you try to unload your kernel and try starting it again? Or simply switch your notebook to another kernel and back to the one with cv2 installed and let us know if you are still seeing the same issue.

When you update a code environment and your notebook kernel is already loaded it will fail to detect new packages installed in the code env. 

Thanks, 

FSeifeldin
Level 1
Author

Thanks Alex for your help. I did as you said, and my code notebook ran successfully without any errors. However, when I created a code recipe from the notebook and ran the recipe, it gave me the same error even though it runs perfectly in the notebook. recipe error.PNG

I checked that the recipe is using the same code environment. I even tried to change the code env for the recipe then change it back again to the correct one and run the recipe, but it still gives me the same error. I also did not change anything in the code env, so I am not sure why this is happening.

Thanks again for your help!

0 Kudos
AlexT
Dataiker

Can you confirm if spicy is installed in your code env?

Perhaps some of the packages were removed and code env still loaded by the notebook still has those packages. 

Are you using local execution or containerized execution for your recipe? 

Can you try using local execution after checking that spicy is in Packages to install and updating the code env:

Screenshot 2022-02-08 at 15.12.22.png

If the issue persists you may want to open a support ticket with the job diagnostics and code env diagnostics for us to review further.

tgb417

@FSeifeldin 

I’ve had similar problems.  Between notebooks and recipes.  In my case it is often that I need to go into the advanced tab on the recipe and select a code environment as well.

This knowledge base post shows the three main places I know of to control which code environment you are using.  https://knowledge.dataiku.com/latest/courses/advanced-code/work-environment/code-env.html
 

--Tom