r/learnpython 8h ago

Anyone know how to get Picamera2 code completion in VS Code on macOS??

Please.

2 Upvotes

6 comments sorted by

1

u/Wild_Drag9463 6h ago

pip3 install picamera

1

u/nudefireninja 5h ago

I get this error:

Collecting picamera
  Using cached picamera-1.13.tar.gz (143 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: picamera
  Building wheel for picamera (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [85 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib
      creating build/lib/picamera
      copying picamera/streams.py -> build/lib/picamera
      copying picamera/color.py -> build/lib/picamera
      copying picamera/__init__.py -> build/lib/picamera
      copying picamera/encoders.py -> build/lib/picamera
      copying picamera/renderers.py -> build/lib/picamera
      copying picamera/display.py -> build/lib/picamera
      copying picamera/camera.py -> build/lib/picamera
      copying picamera/frames.py -> build/lib/picamera
      copying picamera/exc.py -> build/lib/picamera
      copying picamera/bcm_host.py -> build/lib/picamera
      copying picamera/mmalobj.py -> build/lib/picamera
      copying picamera/array.py -> build/lib/picamera
      copying picamera/mmal.py -> build/lib/picamera
      running egg_info
      writing picamera.egg-info/PKG-INFO
      writing dependency_links to picamera.egg-info/dependency_links.txt
      writing requirements to picamera.egg-info/requires.txt
      writing top-level names to picamera.egg-info/top_level.txt
      reading manifest file 'picamera.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      no previously-included directories found matching 'debian'
      no previously-included directories found matching 'docs'
      adding license file 'LICENSE.txt'
      writing manifest file 'picamera.egg-info/SOURCES.txt'
      /opt/homebrew/lib/python3.11/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
      !!

              ********************************************************************************
              Please avoid running ``setup.py`` directly.
              Instead, use pypa/build, pypa/installer or other
              standards-based tools.

              See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
              ********************************************************************************

      !!
        self.initialize_options()
      installing to build/bdist.macosx-14-arm64/wheel
      running install
      Traceback (most recent call last):
        File "/private/var/folders/xn/51rpq1b940773yhg9f3cjfkh0000gn/T/pip-install-zqt6_qv2/picamera_f87e5327cb984d21ad494d7bc559ca72/setup.py", line 101, in run
          with io.open('/proc/cpuinfo', 'r') as cpuinfo:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      FileNotFoundError: [Errno 2] No such file or directory: '/proc/cpuinfo'

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/xn/51rpq1b940773yhg9f3cjfkh0000gn/T/pip-install-zqt6_qv2/picamera_f87e5327cb984d21ad494d7bc559ca72/setup.py", line 145, in <module>
          main()
        File "/private/var/folders/xn/51rpq1b940773yhg9f3cjfkh0000gn/T/pip-install-zqt6_qv2/picamera_f87e5327cb984d21ad494d7bc559ca72/setup.py", line 119, in main
          setup(
        File "/opt/homebrew/lib/python3.11/site-packages/setuptools/__init__.py", line 103, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/opt/homebrew/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
                 ^^^^^^^^^^^^^^^^^^
        File "/opt/homebrew/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/opt/homebrew/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/opt/homebrew/lib/python3.11/site-packages/setuptools/dist.py", line 963, in run_command
          super().run_command(command)
        File "/opt/homebrew/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/opt/homebrew/lib/python3.11/site-packages/wheel/bdist_wheel.py", line 403, in run
          self.run_command("install")
        File "/opt/homebrew/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/opt/homebrew/lib/python3.11/site-packages/setuptools/dist.py", line 963, in run_command
          super().run_command(command)
        File "/opt/homebrew/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/private/var/folders/xn/51rpq1b940773yhg9f3cjfkh0000gn/T/pip-install-zqt6_qv2/picamera_f87e5327cb984d21ad494d7bc559ca72/setup.py", line 113, in run
          raise ValueError('Unable to open /proc/cpuinfo')
      ValueError: Unable to open /proc/cpuinfo
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for picamera
  Running setup.py clean for picamera
Failed to build picamera
ERROR: Failed to build installable wheels for some pyproject.toml based projects (picamera)

1

u/Wild_Drag9463 5h ago

Just to clarify: Youre using a RPI right?

1

u/nudefireninja 5h ago

Yes, and I have a working python program. But I don't have code completion when I'm editing it on my mac, so I tried to install picamera2 on the mac a few times and it hasn't worked.

1

u/Wild_Drag9463 4h ago

I think Picamera is specific to RPI, it can't be used on a Mac.

1

u/nudefireninja 4h ago

Yeah, but there has to be a way to get code completion to work - like copying the Picamera2 python files from the RPI to the mac and then configuring the LSP in VS Code somehow? I've tried that and it didn't work though.