No module named 'pyzed.sl' on Windows

Hello,

I’m new to the ZED 2 camera. I ran to the similar problem as a couple other posts, which results in the error ModuleNotFoundError: No module named 'pyzed.sl'; 'pyzed' is not a package when running the example script. Though I tried to fix the problem, I wasn’t able to resolve it.

I’m using:
Windows 10
Python: 3.8.5
ZED SDK: 3.8

I am running the example in a virtual environment (yes I installed it in the virtual environment and yes it is activated), following your guide to set it up.

I ran the get_python_api.py script which results in the following output:

-> Downloading to 'C:\Program Files (x86)\ZED SDK'
Detected platform:
         win_amd64
         Python 3.8
         ZED SDK 3.8
-> Checking if https://download.stereolabs.com/zedsdk/3.8/whl/win_amd64/pyzed-3.8-cp38-cp38-win_amd64.whl exists and is available
-> Found ! Downloading python package into C:\Program Files (x86)\ZED SDK\pyzed-3.8-cp38-cp38-win_amd64.whl
-> Installing necessary dependencies
Requirement already satisfied: numpy in c:\users\usr\anaconda3\envs\zed_env\env\lib\site-packages (1.24.3)
Processing c:\program files (x86)\zed sdk\pyzed-3.8-cp38-cp38-win_amd64.whl
Collecting numpy>=1.13 (from pyzed==3.8)
  Using cached numpy-1.24.3-cp38-cp38-win_amd64.whl (14.9 MB)
Collecting cython>=0.28 (from pyzed==3.8)
  Using cached Cython-0.29.34-py2.py3-none-any.whl (988 kB)
Installing collected packages: numpy, cython, pyzed
Successfully installed cython-0.29.34 numpy-1.24.3 pyzed-3.8
Done
Installing OpenGL dependencies required to run the samples
-> Downloading PyOpenGL-3.1.5-cp38-cp38-win_amd64.whl
Processing c:\program files (x86)\zed sdk\pyopengl-3.1.5-cp38-cp38-win_amd64.whl
PyOpenGL is already installed with the same version as the provided wheel. Use --force-reinstall to force an installation of the wheel.
-> Downloading PyOpenGL_accelerate-3.1.5-cp38-cp38-win_amd64.whl
Processing c:\program files (x86)\zed sdk\pyopengl_accelerate-3.1.5-cp38-cp38-win_amd64.whl
PyOpenGL-accelerate is already installed with the same version as the provided wheel. Use --force-reinstall to force an installation of the wheel.
Pyzed directory is c:\users\usr\anaconda3\envs\zed_env\env\lib\site-packages

If I check the pyzed version i get the following output:

Name: pyzed
Version: 3.8
Summary: Use the ZED SDK with Python
Home-page: https://github.com/stereolabs/zed-python-api
Author:
Author-email: developers@stereolabs.com
License: UNKNOWN
Location: c:\users\usr\anaconda3\envs\zed_env\env\lib\site-packages
Requires: cython, numpy
Required-by:

But if I look in the Anaconda Navigator for the packages in the virtual environment it won’t show up.

If I run the example script it produces the following error:

ModuleNotFoundError: No module named 'pyzed.sl'; 'pyzed' is not a package

What are the steps to fix that error?

Thanks a lot!

Hi,

It seems you know how to work with virtual envs, but it’s probably a virtual env issue. Are you use you are running the tutorial script in the same virtual env than you ran get_python_api.py ? Can you send the exact command line you send ?
Are you using python3 and not python (which is python2) ?

Thanks a lot for your quick response.

I only have one virtual environment, so I’m confident it’s in the same environment.

I used the following command line:
cd C:\Program Files (x86)\ZED SDK

and:
python3 get_python_api.py

and I’m running the script in a jupyter notebook, where is switched to the virtual environment.

I also tried setting it up without the virtual environment, but it resulted in the same output as shown in my answer before.

what if, outside of your jupyter notebook, right after cd C:\Program Files (x86)\ZED SDK, you run
python3 -m pip show pyzed
and then, still in the same console, you run one of our tutorials with python3 <path-to-tutorial-1>/hello.py?

when I run python3 -m pip show pyzed right after the cd command the output is:

Name: pyzed
Version: 3.8
Summary: Use the ZED SDK with Python
Home-page: https://github.com/stereolabs/zed-python-api
Author:
Author-email: developers@stereolabs.com
License: UNKNOWN
Location: c:\users\usr\anaconda3\envs\zed_env\env\lib\site-packages
Requires: cython, numpy
Required-by:

when I run the second command you suggested, the output I get is the following:

Traceback (most recent call last):
  File "hello_zed.py", line 21, in <module>
    import pyzed.sl as sl
ImportError: DLL load failed while importing sl: Das angegebene Modul wurde nicht gefunden.

If I run those commands outside the virtual environment I get similar outputs:

WARNING: Ignoring invalid distribution -yyaml (c:\users\usr\appdata\local\programs\python\python38\lib\site-packages)
Name: pyzed
Version: 3.8
Summary: Use the ZED SDK with Python
Home-page: https://github.com/stereolabs/zed-python-api
Author:
Author-email: developers@stereolabs.com
License: UNKNOWN
Location: c:\users\usr\appdata\local\programs\python\python38\lib\site-packages
Requires: cython, numpy
Required-by:

and:

Traceback (most recent call last):
  File "hello_zed.py", line 21, in <module>
    import pyzed.sl as sl
ImportError: DLL load failed while importing sl: Das angegebene Modul wurde nicht gefunden.

(The last sentence should translate to: module not found)

I also tried to copy the dll files from C:\Program Files (x86)\ZED SDK\bin into the pyzed folder. Which also results in the same output.

Hi,

This error is actually quite different than Module not found. It finds the python module correctly, but fails to find some dependencies it has. It’s kind of typical these days when using virtual environment on windows, unfortunately.
The first step is indeed to copy the dlls from ZED SDK : sl_zed.dll and sl_ai.dll into the pyzed folder.
If that’s not enough, you can download a dependency walker tool (like this one) and use it on the pyzediot module (which is in the pyzed folder, and is named something like sl.cpython-310-x86_64-linux-gnu.xx)
Usually, what’s missing is from nvidia, for example nvencodeapi.dll, this kind of stuff.

Thanks a lot, that seems to have been the problem.

Adding the file nvEncodeAPI64.dll did the trick for me.

Thanks for your time!

Hi,I had the same problem. Can you tell me how you did it?