Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyrealsense2 has no attribute 'context' #11671

Closed
futuristic2023 opened this issue Apr 12, 2023 · 5 comments
Closed

pyrealsense2 has no attribute 'context' #11671

futuristic2023 opened this issue Apr 12, 2023 · 5 comments
Labels

Comments

@futuristic2023
Copy link

    ctx = rs.context()
    devices = ctx.query_devices()

    if args.camid >= len(devices):
        print(f"Error: Camera ID {args.camid} not found. Exiting.")
        return

    serial_number = devices[args.camid].get_info(rs.camera_info.serial_number)

    pipeline = rs.pipeline()
    config = rs.config()

i am getting this error the pyrealsense2 has no attribute context?
please help .. soon

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Apr 12, 2023

Hi @shivangi-futuristicbots There are only a couple of past cases of this error that have been reported on this librealsense support site. A suggested solution by RealSense users in both cases was to change 'import pyrealsense2 as rs' to:

import pyrealsense2.pyrealsense2 as rs

@futuristic2023
Copy link
Author

i am getting this error after suggested changes you given:

   import pyrealsense2.pyrealsense2 as rs
ModuleNotFoundError: No module named 'pyrealsense2.pyrealsense2'; 'pyrealsense2' is not a package

@MartyG-RealSense
Copy link
Collaborator

Can you confirm please that you have an import pyrealsense2 as rs instruction placed before your ctx instruction?

import pyrealsense2 as rs
ctx = rs.context()
devices = ctx.query_devices()

#1735 (comment) has a Python example of using these lines for two RealSense cameras.

If your project only uses one camera then it may not be necessary to use rs.context() (which is typically used to build a list of all attached cameras in a multiple camera application). The RealSense SDK's single-camera pyrealsense2 example programs at the link below do not use ctx.

https://github.com/IntelRealSense/librealsense/tree/master/wrappers/python/examples

@futuristic2023
Copy link
Author

futuristic2023 commented Apr 14, 2023

yes i import the statement : import pyrealsense2 as rs

OK if i remove this lines of codes:
ctx = rs.context()
devices = ctx.query_devices()

and then i get this error:

 pipeline = rs.pipeline()
AttributeError: module 'pyrealsense2' has no attribute 'pipeline'

i already check the pyrealsense2 package and it is already installed:

Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
Requirement already satisfied: pyrealsense2 in /home/workspace/YOLOX/venv/lib/python3.10/site-packages (2.53.1.4623)

@aditya7robo
Copy link

@futuristic2023 How did you solve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants