'pyzed' has no attribute 'Matrix4f'

Traceback (most recent call last):
File “c:\Program Files (x86)\ZED SDK\samples\spatial mapping\spatial mapping\python\spatial_mapping.py”, line 174, in
File “c:\Program Files (x86)\ZED SDK\samples\spatial mapping\spatial mapping\python\spatial_mapping.py”, line 71, in main
viewer = gl.GLViewer()
File “c:\Program Files (x86)\ZED SDK\samples\spatial mapping\spatial mapping\python\ogl_viewer\viewer.py”, line 212, in init
self.projection = sl.Matrix4f()
AttributeError: module ‘pyzed’ has no attribute ‘Matrix4f’

I sucessfully downloaded python api,and pyzed.sl worked when I put dll files correctly. Then I run spatial mapping.py in samples, and I got this problem. Any idea for this? I didn’t changed anything from the sample code. I think its the reason why the viewer didn’t appear.

Hi @skgr07 ,

I quickly tried on my side with SDK 4.0.5 but could not reproduce, it works as expected (and Intellisense knows Matrix4f).

What version of the SDK are you using, what version of python and what is your OS, please?

spatial_mapping.py (7.5 KB)
here is my file. i’m working in Windows 11 with python 3.10.12, Zed, and I do not know the exact version, but the first line of the zed-config-version file says the version is 4.0.5. The viewer does not appear, and since i don’t know what Matrix4f is, I can’t solve it. The depth sensing sample works well with a viewer.
If possible, can you send me the file with no error?


@skgr07 Ok, seems to be 4.0.5 then. You can check it by running a tool like ZED Explorer, it will be written at the bottom.

I was able to run your code without issues on Python 3.10, but I don’t use anaconda. Can you try running the script directly from the python executable in command line (like a powershell python.exe .\spatial_mapping.py)?

If it doesn’t work, can you try re-running the get_python_api.py script and try again?

I tried it without conda, and I got new error like this. Where is the right directory for pyopengl whl files? I think I should move it manually. the files were install in c:users, not in the right path.

@skgr07 I saw your other topic, thanks for separating the issue, we’ll address it over there shortly.

Back to Conda, can you run the command conda env export > environment.yaml in your Conda environment? (And share the resulting environment.yaml file)

This will help replicate your environment and the issue.

here is the environment file.
environment.yaml (14.7 KB)

I think the problems comes from how you run pip.
You should not use

pip install XXX

but rather

python3 -m pip install XXX

to be sure that it get installed in the right environment. can you do that with pyopengl ?

This is What I got when i pip installed pyopengl.
Pyopengl is installed, but still the error occurs.

You should read my previous response, I just told you that you cannot use pip like in your screenshot.

Apology for the wrong screenshot. I tried it, but in the terminal it just prints "python"and doesn’t seem to install things. So I used pip again.

It looks like the command you typed started python instead of running pip install. Can you share the exact output of the command python3 -m pip install pyopengl ?

This is what I got when I run get python api

And this is what I got when I run python3 -m pip install pyopengl.

so I tried python.exe -m pip install pyopengl.

I also tried python.exe -m pip install --force-reinstall pyopengl , but it didn’t seem to work.

Well, the last capture says that pyopengl is installed correctly. Do you still have errors with your actual app ?

Yes, the Matrix4f error still exists…

The Matrix one, and not opengl one. Back from where we started.

Now in the same python env, with python.exe -m pip, can you install the pyzed .whl file ? with --force-reinstall.

I first use
python.exe -m pip install --force-reinstall pyzed
And I used pip to check if pyzed was installed correctly.
The pyzed package was install in the right directory.

And this is what I got.

this is pyzed package folder. Is there any files missing?

I first use
python.exe -m pip install --force-reinstall pyzed
And I used pip to check if pyzed was installed correctly.
The pyzed package was install in the right directory.
화면 캡처 2023-07-28 004640
And this is what I got.
화면 캡처 2023-07-28 004952
this is pyzed package folder. Is there any files missing?
화면 캡처 2023-07-28 005103

[Discourse post]

It seems that you are in a situation with pyzed installed in your conda environment python 3.10 and pyopenGL and numpy installed in your local python repertory 3.11

Can you run :
- run C:\Users\user\AppData\Local\Programs\Python\Python311>python.exe get_python_api.py
- run C:\Users\user\AppData\Local\Programs\Python\Python311>python.exe -m pip install numpy
- run C:\Users\user\AppData\Local\Programs\Python\Python311>python.exe -m pip install cython
- run the line at the end of get_python_api.py, something like python.exe -m pip install --force-reinstall pyzed-*.**.whl, with the same python.exe as the others.
- run C:\Users\user\AppData\Local\Programs\Python\Python311>python.exe -m pip install pyopengl

And then test your sample ? Please send all the logs that you get.
It should also work if you type all the commands in your conda enviroment, as long as you use the same python for all commands.

it can’t open the file get python api, so i run get python api directly.
And this is what I got.

I tried force reinstall pyzed and opengl
Requirement already satisfied: pyopengl in c:\users\user\appdata\local\programs\python\python311\lib\site-packages (3.1.7)

There are error messages with tensorflow and numpy’s version, but I don’t think this contributes to our problem.