get_python_api.py is unable to find pyzed installation folder
Preliminary Checks
- [X] This issue is not a duplicate. Before opening a new issue, please search existing issues.
- [X] This issue is not a question, feature request, or anything other than a bug report directly related to this project.
Description
Hi,
I was trying to install the ZED Python API following this instructions. When running the get_python_api.py script, I got the following error:
C:\Program Files (x86)\ZED SDK>python get_python_api.py
-> Downloading to 'C:\Program Files (x86)\ZED SDK'
Detected platform:
win
Python 3.10
ZED SDK 3.7
-> Checking if https://download.stereolabs.com/zedsdk/3.7/win/py310 exists and is available
-> Found ! Downloading python package into C:\Program Files (x86)\ZED SDK\pyzed-3.7-cp310-cp310-win_amd64.whl
-> Installing necessary dependencies
Requirement already satisfied: numpy in c:\users\[name]\appdata\roaming\python\python310\site-packages (1.23.1)
Processing c:\program files (x86)\zed sdk\pyzed-3.7-cp310-cp310-win_amd64.whl
Collecting cython>=0.28
Using cached Cython-0.29.32-py2.py3-none-any.whl (986 kB)
Collecting numpy>=1.13
Using cached numpy-1.23.3-cp310-cp310-win_amd64.whl (14.6 MB)
Installing collected packages: numpy, cython, pyzed
Successfully installed cython-0.29.32 numpy-1.23.3 pyzed-3.7
Done
Installing OpenGL dependencies required to run the samples
-> Downloading PyOpenGL-3.1.6-cp310-cp310-win_amd64.whl
Processing c:\program files (x86)\zed sdk\pyopengl-3.1.6-cp310-cp310-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.6-cp310-cp310-win_amd64.whl
Processing c:\program files (x86)\zed sdk\pyopengl_accelerate-3.1.6-cp310-cp310-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.
ERROR : not a directory
ERROR : Unable to find pyzed installation folder
['Name: pyzed', 'Version: 3.7', 'Summary: Use the ZED SDK with Python', 'Home-page: https://github.com/stereolabs/zed-python-api', 'Author: ', 'Author-email: [email protected]', 'License: UNKNOWN', 'Location: c:\\program files\\python310\\lib\\site-packages', 'Requires: cython, numpy', 'Required-by: ']
Traceback (most recent call last):
File "C:\Program Files (x86)\ZED SDK\get_python_api.py", line 357, in <module>
shutil.copy(source_dir + file, pyzed_dir + file)
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
Looking at the get_python_api.py script I noticed that it is unable to find the pyzed installation folder, stated in the get_pyzed_directory() function. The pyzed installation folder is here:
c:/program files/python310/lib/site-packages/pyzed
The problem is that, to find the pyzed installation folder, you just split the lines from the command pip show pyzed by space character in line 73 which causes the error. It will return a list which on my machine looks like this ['Location:', 'c:\program', 'files\python310\lib\site-packages'] and is of course incorrect when you expect the pyzed installation folder on list-index 1 (line 76).
You can fix it like this:
def get_pyzed_directory():
try:
call_list = [sys.executable, "-m", "pip", "show", "pyzed"]
lines = subprocess.check_output(call_list).decode().splitlines()
key_word = "Location:"
for line in lines:
if line.startswith(key_word):
directory = line[len(key_word):].strip()
if os.path.isdir(directory):
print("Pyzed directory is " + directory)
return directory + "/pyzed"
else:
print("ERROR : not a directory")
print("ERROR : Unable to find pyzed installation folder")
print(lines)
except Exception as e:
print("ERROR : Unable to find pyzed installation folder.")
return ""
Steps to Reproduce
- Execute
pip show pyzed - Have a location with a space character in it (like
c:/program files/python310/lib/site-packages/pyzed) - See the error by executing
get_python_api.py
Expected Result
C:\Program Files (x86)\ZED SDK>python get_python_api.py
-> Downloading to 'C:\Program Files (x86)\ZED SDK'
Detected platform:
win
Python 3.10
ZED SDK 3.7
-> Checking if https://download.stereolabs.com/zedsdk/3.7/win/py310 exists and is available
-> Found ! Downloading python package into C:\Program Files (x86)\ZED SDK\pyzed-3.7-cp310-cp310-win_amd64.whl
-> Installing necessary dependencies
Requirement already satisfied: numpy in c:\users\[name]\appdata\roaming\python\python310\site-packages (1.23.1)
Processing c:\program files (x86)\zed sdk\pyzed-3.7-cp310-cp310-win_amd64.whl
Collecting cython>=0.28
Using cached Cython-0.29.32-py2.py3-none-any.whl (986 kB)
Collecting numpy>=1.13
Using cached numpy-1.23.3-cp310-cp310-win_amd64.whl (14.6 MB)
Installing collected packages: numpy, cython, pyzed
Successfully installed cython-0.29.32 numpy-1.23.3 pyzed-3.7
Done
Installing OpenGL dependencies required to run the samples
-> Downloading PyOpenGL-3.1.6-cp310-cp310-win_amd64.whl
Processing c:\program files (x86)\zed sdk\pyopengl-3.1.6-cp310-cp310-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.6-cp310-cp310-win_amd64.whl
Processing c:\program files (x86)\zed sdk\pyopengl_accelerate-3.1.6-cp310-cp310-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:\program files\python310\lib\site-packages
To install it later or on a different environment run :
python -m pip install --ignore-installed C:\Program Files (x86)\ZED SDK\pyzed-3.7-cp310-cp310-win_amd64.whl
Actual Result
C:\Program Files (x86)\ZED SDK>python get_python_api.py
-> Downloading to 'C:\Program Files (x86)\ZED SDK'
Detected platform:
win
Python 3.10
ZED SDK 3.7
-> Checking if https://download.stereolabs.com/zedsdk/3.7/win/py310 exists and is available
-> Found ! Downloading python package into C:\Program Files (x86)\ZED SDK\pyzed-3.7-cp310-cp310-win_amd64.whl
-> Installing necessary dependencies
Requirement already satisfied: numpy in c:\users\[name]\appdata\roaming\python\python310\site-packages (1.23.1)
Processing c:\program files (x86)\zed sdk\pyzed-3.7-cp310-cp310-win_amd64.whl
Collecting cython>=0.28
Using cached Cython-0.29.32-py2.py3-none-any.whl (986 kB)
Collecting numpy>=1.13
Using cached numpy-1.23.3-cp310-cp310-win_amd64.whl (14.6 MB)
Installing collected packages: numpy, cython, pyzed
Successfully installed cython-0.29.32 numpy-1.23.3 pyzed-3.7
Done
Installing OpenGL dependencies required to run the samples
-> Downloading PyOpenGL-3.1.6-cp310-cp310-win_amd64.whl
Processing c:\program files (x86)\zed sdk\pyopengl-3.1.6-cp310-cp310-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.6-cp310-cp310-win_amd64.whl
Processing c:\program files (x86)\zed sdk\pyopengl_accelerate-3.1.6-cp310-cp310-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.
ERROR : not a directory
ERROR : Unable to find pyzed installation folder
['Name: pyzed', 'Version: 3.7', 'Summary: Use the ZED SDK with Python', 'Home-page: https://github.com/stereolabs/zed-python-api', 'Author: ', 'Author-email: [email protected]', 'License: UNKNOWN', 'Location: c:\\program files\\python310\\lib\\site-packages', 'Requires: cython, numpy', 'Required-by: ']
Traceback (most recent call last):
File "C:\Program Files (x86)\ZED SDK\get_python_api.py", line 357, in <module>
shutil.copy(source_dir + file, pyzed_dir + file)
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
ZED Camera model
ZED2i
Environment
OS: Windows 10 Pro
CPU: AMD Ryzen 9
GPU: NVIDIA RTX 3090
ZED SDK version: v3.7.7
Anything else?
No response
Hi,
Thank you for the detailed report! You're right the current way was too brittle. We'll integrate your fix for the next release
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment otherwise it will be automatically closed in 5 days