Week 1 Ungraded Lab - cv2 not found

says cv2 package not found even though I ran pip install requirements.txt in my terminal prior. Note that this error showed up when I used the virtual environment method (method 1), but not with the Docker method (method 2).

hi @chengyineng , can you give more information about which OS you are using and the output of the following command?

conda env list and pip freeze

And make sure you do activate the environment by conda activate mlep-w1-lab .

I only checked it on Linux and it works flawlessly.

Having the same issue getting error below. I did followed all steps in the instruction and made sure I activated the env and pip installed the requirement.txt.

"---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
in
----> 1 import cvlib

ModuleNotFoundError: No module named ‘cvlib’"

output from conda env list:

conda environments:

my_py3_7 /Users/mc/.conda/envs/my_py3_7
test1 /Users/mc/.conda/envs/test1
/Users/mc/miniconda3
base /Users/mc/opt/anaconda3
mlep-w1-lab * /Users/mc/opt/anaconda3/envs/mlep-w1-lab
mlep-w1-lab2 /Users/mc/opt/anaconda3/envs/mlep-w1-lab2
tf2 /Users/mc/opt/anaconda3/envs/tf2

output from pip freeze:

absl-py==0.12.0

anyio==3.1.0

appnope==0.1.2

argon2-cffi==20.1.0

astunparse==1.6.3

async-generator==1.10

attrs==21.2.0

Babel==2.9.1

backcall==0.2.0

bleach==3.3.0

cachetools==4.2.2

certifi==2020.12.5

cffi==1.14.5

chardet==4.0.0

click==7.1.2

cvlib==0.2.5

decorator==5.0.9

defusedxml==0.7.1

entrypoints==0.3

fastapi==0.63.0

gast==0.3.3

google-auth==1.30.1

google-auth-oauthlib==0.4.4

google-pasta==0.2.0

grpcio==1.38.0

h11==0.12.0

h5py==2.10.0

idna==2.10

imageio==2.9.0

importlib-metadata==4.0.1

imutils==0.5.4

ipykernel==5.5.5

ipython==7.23.1

ipython-genutils==0.2.0

jedi==0.18.0

Jinja2==3.0.1

json5==0.9.5

jsonschema==3.2.0

jupyter-client==6.1.12

jupyter-core==4.7.1

jupyter-server==1.8.0

jupyterlab==3.0.5

jupyterlab-pygments==0.1.2

jupyterlab-server==2.5.2

Keras-Preprocessing==1.1.2

Markdown==3.3.4

MarkupSafe==2.0.1

matplotlib-inline==0.1.2

mistune==0.8.4

nbclassic==0.3.1

nbclient==0.5.3

nbconvert==6.0.7

nbformat==5.1.3

nest-asyncio==1.5.1

notebook==6.4.0

numpy==1.18.5

oauthlib==3.1.0

opencv-python-headless==4.4.0.46

opt-einsum==3.3.0

packaging==20.9

pandocfilters==1.4.3

parso==0.8.2

pexpect==4.8.0

pickleshare==0.7.5

Pillow==8.0.1

progressbar==2.5

prometheus-client==0.10.1

prompt-toolkit==3.0.18

protobuf==3.17.1

ptyprocess==0.7.0

pyasn1==0.4.8

pyasn1-modules==0.2.8

pycparser==2.20

pydantic==1.8.2

Pygments==2.9.0

pyparsing==2.4.7

pyrsistent==0.17.3

python-dateutil==2.8.1

python-multipart==0.0.5

pytz==2021.1

pyzmq==22.0.3

requests==2.25.1

requests-oauthlib==1.3.0

rsa==4.7.2

Send2Trash==1.5.0

six==1.16.0

sniffio==1.2.0

starlette==0.13.6

tensorboard==2.5.0

tensorboard-data-server==0.6.1

tensorboard-plugin-wit==1.8.0

tensorflow==2.3.1

tensorflow-estimator==2.3.0

termcolor==1.1.0

terminado==0.10.0

testpath==0.5.0

tornado==6.1

traitlets==5.0.5

typing-extensions==3.10.0.0

urllib3==1.26.4

uvicorn==0.12.2

wcwidth==0.2.5

webencodings==0.5.1

websocket-client==1.0.1

Werkzeug==2.0.1

wrapt==1.12.1

zipp==3.4.1

hi @morrischen2008 , for the result of pip freeze and conda env list I see all the packages are in place. I’m not sure why you cannot import the module.
Can you use docker instead? When you import the module, there seem some error occurred, did you see some hints about the cause from the error message?

Looks like you’re using a Mac, I tried on my Intel Macbook Pro and cannot get the same error.

Thanks! I still cannot figure out why using conda (method 1), importing cvlib fails. But using docker (method 2), cvlib can be imported successfully.

sorry cannot help you here.
From the environment list, I see you have mixed miniconda and anaconda installed. And the paths to each environment are different.
I am not sure this is a solution but you can try to uninstall all the miniconda and anaconda, clear the path in .bash_profile, then try to install anaconda again.

No worries and thanks for your advice! I will try clear things up as you suggested when I revisit this homework later.

1 Like

I have the same issue on Windows. I probably have both Miniconda and Anaconda installed as you mentioned.

I re-installed Anaconda and that did not fix it. But I had been opening Jupyter using a different method instead of typing jupyter lab at the Anaconda prompt like the instructions say. When I opened Jupyter using the instructions, cvlib loaded.

1 Like

Posting this solution from other learner:

1 Like

Thanks, this worked for me.