# C1W1 ungraded lab import cvlib error

**URL:** <https://community.deeplearning.ai/t/c1w1-ungraded-lab-import-cvlib-error/287879>\
**Category:** Machine Learning in Production\
**Created:** [March 9, 2023, 10:14pm UTC](https://community.deeplearning.ai/t/c1w1-ungraded-lab-import-cvlib-error/287879 "2023-03-09T22:14:38Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim\_Stevens](https://avatars.discourse-cdn.com/v4/letter/t/a183cd/32.png) [@Tim\_Stevens](https://community.deeplearning.ai/u/Tim_Stevens)\
**Post date:** [March 9, 2023, 10:14pm UTC](https://community.deeplearning.ai/t/c1w1-ungraded-lab-import-cvlib-error/287879/1 "2023-03-09T22:14:38Z")

</div>

I followed the install, was not prompted for a token to authenticate. On command [4] in the lab I get a TypeError, from “import cvlib as cv” then a traceback to a number of miniconda tensorflow imports. How do I fix this? I’m on an Intel i9 iMac.

---

<div class="post-metadata">

**Author:** ![Th\_o\_Vy\_Le\_Nguy\_n](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/th_o_vy_le_nguy_n/32/36232_2.png) [@Th\_o\_Vy\_Le\_Nguy\_n](https://community.deeplearning.ai/u/Th_o_Vy_Le_Nguy_n)\
**Post date:** [March 9, 2023, 10:33pm UTC](https://community.deeplearning.ai/t/c1w1-ungraded-lab-import-cvlib-error/287879/2 "2023-03-09T22:33:30Z")

</div>

Hi @Tim_Stevens,  
Welcome to the community.  
Could you send me the error message of authentication during the installation and the TypeError?

Best regards,  
Vy

---

<div class="post-metadata">

**Author:** ![Tim\_Stevens](https://avatars.discourse-cdn.com/v4/letter/t/a183cd/32.png) [@Tim\_Stevens](https://community.deeplearning.ai/u/Tim_Stevens)\
**Post date:** [March 9, 2023, 10:50pm UTC](https://community.deeplearning.ai/t/c1w1-ungraded-lab-import-cvlib-error/287879/3 "2023-03-09T22:50:15Z")

</div>

Thank you! The end of the terminal window during installation is:

```
To access the server, open this file in a browser:
    file:///Users/timdirk/Library/Jupyter/runtime/jpserver-76948-open.html
Or copy and paste one of these URLs:
    http://localhost:8888/lab?token=0c6b8198004b65ef2991c39e5f9b290934549b612f036ddc
 or http://127.0.0.1:8888/lab?token=0c6b8198004b65ef2991c39e5f9b290934549b612f036ddc

```

[W 2023-03-09 14:42:48.567 LabApp] Could not determine jupyterlab build status without nodejs  
[W 2023-03-09 14:43:59.219 LabApp] Could not determine jupyterlab build status without nodejs  
[W 2023-03-09 14:44:36.830 LabApp] Could not determine jupyterlab build status without nodejs  
[W 2023-03-09 14:44:41.866 LabApp] Could not determine jupyterlab build status without nodejs  
[W 2023-03-09 14:45:47.813 ServerApp] Notebook server.ipynb is not trusted  
[I 2023-03-09 14:45:48.145 ServerApp] Kernel started: 72b2bcbe-839a-416d-885c-f3cede75dc2b  
[W 2023-03-09 14:45:48.782 ServerApp] Got events for closed stream \<zmq.eventloop.zmqstream.ZMQStream object at 0x7fa9e03c1f70\>  
[I 2023-03-09 14:47:48.000 ServerApp] Saving file at /server.ipynb  
[I 2023-03-09 14:49:48.021 ServerApp] Saving file at /server.ipynb  
[I 2023-03-09 14:51:48.041 ServerApp] Saving file at /server.ipynb  
[W 2023-03-09 14:53:40.001 LabApp] Could not determine jupyterlab build status without nodejs  
[I 2023-03-09 14:56:37.917 ServerApp] Creating new notebook in  
[I 2023-03-09 14:56:38.096 ServerApp] Kernel started: c927463b-9b01-42c9-9f32-ac09917c7337  
[W 2023-03-09 14:56:38.597 ServerApp] Got events for closed stream \<zmq.eventloop.zmqstream.ZMQStream object at 0x7fa9f0b97c70\>  
[I 2023-03-09 14:58:21.874 ServerApp] Kernel started: 25d969ca-cfff-48c0-af05-90f8ac944074  
[I 2023-03-09 14:58:38.696 ServerApp] Saving file at /Untitled.ipynb  
[I 2023-03-09 14:58:49.383 ServerApp] Starting buffering for 25d969ca-cfff-48c0-af05-90f8ac944074:97e4fd1e-b591-4b7b-a581-c5ae1ce62105  
[I 2023-03-09 15:08:09.451 ServerApp] Saving file at /server.ipynb

The Lab 1 error messages are on step [4] import cv2, etc. as:  
TypeError Traceback (most recent call last)  
Cell In[5], line 2  
1 import cv2  
----\> 2 import cvlib as cv  
3 from cvlib.object\_detection import draw\_bbox  
6 def detect\_and\_draw\_box(filename, model=“yolov3-tiny”, confidence=0.5):

File ~/miniconda3/envs/mlep-w1-lab/lib/python3.8/site-packages/cvlib/ **init**.py:8  
6 from .face\_detection import detect\_face  
7 from .object\_detection import detect\_common\_objects  
----\> 8 from .gender\_detection import detect\_gender  
9 from .utils import get\_frames, animate

File ~/miniconda3/envs/mlep-w1-lab/lib/python3.8/site-packages/cvlib/gender\_detection.py:3  
1 import os  
2 import cv2  
----\> 3 from tensorflow.keras.utils import get\_file  
5 initialize = True  
6 gd = None  
etc. etc.

---

<div class="post-metadata">

**Author:** ![Tim\_Stevens](https://avatars.discourse-cdn.com/v4/letter/t/a183cd/32.png) [@Tim\_Stevens](https://community.deeplearning.ai/u/Tim_Stevens)\
**Post date:** [March 11, 2023, 9:53pm UTC](https://community.deeplearning.ai/t/c1w1-ungraded-lab-import-cvlib-error/287879/4 "2023-03-11T21:53:10Z")

</div>

Help, I am still stuck. Hearing no advice, I started over and repeated the whole installation, but multiple steps failed as directories already had been created by the first installation. So that didn’t work. I see that one can do this lab inside of Coursera “This lab is now available within Coursera. It has some differences with the version that is meant to be run in your local computer as a result of constraints within the Coursera environment. However the core of the lab is kept the same.” but I really don’t want to do that, part of what I wanted to learn from this course is to set up a local installation.

Tim

---

<div class="post-metadata">

**Author:** ![Tim\_Stevens](https://avatars.discourse-cdn.com/v4/letter/t/a183cd/32.png) [@Tim\_Stevens](https://community.deeplearning.ai/u/Tim_Stevens)\
**Post date:** [March 11, 2023, 10:28pm UTC](https://community.deeplearning.ai/t/c1w1-ungraded-lab-import-cvlib-error/287879/5 "2023-03-11T22:28:52Z")

</div>

Well, I gave up on Method 1: Python Virtual Environment with Conda, so tried Method 2: Docker, even though I read somewhere not to use that on Macs. I was encouraged at first, as this did prompt me for authentication and I entered the token from the terminal window. Then I started Lab 1. This didn’t work. The end of the terminal window is:  
To access the notebook, open this file in a browser:  
file:///home/jovyan/.local/share/jupyter/runtime/nbserver-7-open.html  
Or copy and paste one of these URLs:  
[http://5f9adc12b536:8888/?token=c7893202174fad24195ce2e61253bee97206eaed674d3c6d](http://5f9adc12b536:8888/?token=c7893202174fad24195ce2e61253bee97206eaed674d3c6d)  
or [http://127.0.0.1:8888/?token=c7893202174fad24195ce2e61253bee97206eaed674d3c6d](http://127.0.0.1:8888/?token=c7893202174fad24195ce2e61253bee97206eaed674d3c6d)  
[W 22:18:49.475 NotebookApp] Clearing invalid/expired login cookie username-localhost-8888  
[W 2023-03-11 22:18:49.476 LabApp] Clearing invalid/expired login cookie username-localhost-8888  
[I 22:18:49.476 NotebookApp] 302 GET /lab (172.17.0.1) 1.430000ms  
[I 22:19:05.818 NotebookApp] 302 POST /login?next=%2Flab (172.17.0.1) 0.730000ms  
[I 22:19:05.889 NotebookApp] 301 GET /static/favicons/favicon.ico (172.17.0.1) 0.320000ms  
[I 2023-03-11 22:19:08.115 LabApp] Build is up to date  
[I 22:19:59.479 NotebookApp] Writing notebook-signing key to /home/jovyan/.local/share/jupyter/notebook\_secret  
[W 22:19:59.481 NotebookApp] Notebook work/server.ipynb is not trusted  
[I 22:19:59.864 NotebookApp] Kernel started: 452a247e-030c-4b58-b7c2-bf14c81a1e5e, name: python3  
[I 22:20:00.307 NotebookApp] 301 GET /static/favicons/favicon.ico (172.17.0.1) 0.280000ms  
[I 22:20:09.249 NotebookApp] 301 GET /static/favicons/favicon.ico (172.17.0.1) 0.320000ms  
[I 22:20:14.129 NotebookApp] 301 GET /static/favicons/favicon.ico (172.17.0.1) 0.290000ms  
[I 22:20:25.252 NotebookApp] 301 GET /static/favicons/favicon.ico (172.17.0.1) 0.290000ms  
2023-03-11 22:20:34.597261: W tensorflow/stream\_executor/platform/default/dso\_loader.cc:64] Could not load dynamic library ‘libcudart.so.11.0’; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory  
2023-03-11 22:20:34.597324: I tensorflow/stream\_executor/cuda/cudart\_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.  
[I 22:21:59.966 NotebookApp] Saving file at /work/server.ipynb

## and the Lab 1 error on step [4] import cv2 is:

NameError Traceback (most recent call last)  
Cell In[6], line 2  
1 for image\_file in image\_files:  
----\> 2 detect\_and\_draw\_box(image\_file)

NameError: name ‘detect\_and\_draw\_box’ is not defined

So I am still stuck, and hoping for advice from experts here!

Tim

---

<div class="post-metadata">

**Author:** ![Th\_o\_Vy\_Le\_Nguy\_n](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/th_o_vy_le_nguy_n/32/36232_2.png) [@Th\_o\_Vy\_Le\_Nguy\_n](https://community.deeplearning.ai/u/Th_o_Vy_Le_Nguy_n)\
**Post date:** [March 12, 2023, 1:48pm UTC](https://community.deeplearning.ai/t/c1w1-ungraded-lab-import-cvlib-error/287879/6 "2023-03-12T13:48:53Z")

</div>

Hi @Tim_Stevens,

I’ve been trying to recreate your issue but nothing happened. I’ve informed other mentors and staff to see if they can help. In the mean times, you can continue with other labs.

Best regards,  
Vy

---

<div class="post-metadata">

**Author:** ![Felix\_Schneider](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/felix_schneider/32/49363_2.png) [@Felix\_Schneider](https://community.deeplearning.ai/u/Felix_Schneider)\
**Post date:** [April 13, 2023, 6:42pm UTC](https://community.deeplearning.ai/t/c1w1-ungraded-lab-import-cvlib-error/287879/7 "2023-04-13T18:42:38Z")

</div>

Here is the `TypeError`:

> TypeError: Descriptors cannot not be created directly.  
> If this call came from a \_pb2.py file, your generated code is out of date and must be regenerated with protoc \>= 3.19.0.  
> If you cannot immediately regenerate your protos, some other possible workarounds are:
> 
> 1. Downgrade the protobuf package to 3.20.x or lower.
> 2. Set PROTOCOL\_BUFFERS\_PYTHON\_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
> 
> More information: [Changes announced May 6, 2022 | Protocol Buffers Documentation](https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates)

The installed version of protobuf is 4.22.3

I downgraded protobuf with

> conda install “protobuf\<=3.20”

With this, the `cvlib` import passes without any errors.

So far I did not fninish the lab, so I can’t tell if downgrading protobuf will lead to problems elsewhere.

Hope this helps  
Felix

---

<div class="post-metadata">

**Author:** ![Kaltham](https://avatars.discourse-cdn.com/v4/letter/k/2acd7d/32.png) [@Kaltham](https://community.deeplearning.ai/u/Kaltham)\
**Post date:** [May 2, 2023, 12:34pm UTC](https://community.deeplearning.ai/t/c1w1-ungraded-lab-import-cvlib-error/287879/8 "2023-05-02T12:34:13Z")

</div>

I also downgraded to 3.20 and managed to finish the lab with no issues

---

<div class="post-metadata">

**Author:** ![Basira\_Daqiq](https://avatars.discourse-cdn.com/v4/letter/b/8491ac/32.png) [@Basira\_Daqiq](https://community.deeplearning.ai/u/Basira_Daqiq)\
**Post date:** [August 13, 2023, 5:05am UTC](https://community.deeplearning.ai/t/c1w1-ungraded-lab-import-cvlib-error/287879/9 "2023-08-13T05:05:33Z")

</div>

> [@Felix\_Schneider](#):
>
> conda install “protobuf\<=3.20”

very helpful, downgrading to 3.20 resolved the error

---

<div class="post-metadata">

**Author:** ![zahta](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/zahta/32/62286_2.png) [@zahta](https://community.deeplearning.ai/u/zahta)\
**Post date:** [August 31, 2023, 5:42am UTC](https://community.deeplearning.ai/t/c1w1-ungraded-lab-import-cvlib-error/287879/10 "2023-08-31T05:42:50Z")

</div>

Thanks. `conda install protobuf=3.20` works for me.
