C1W1 ungraded lab import cvlib error

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.

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

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.

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

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
or 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

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

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

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

3 Likes

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

3 Likes

very helpful, downgrading to 3.20 resolved the error

Thanks. conda install protobuf=3.20 works for me.